Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move responsive position utilities from marketing to core #459

Merged
merged 6 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/pages/css/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ utilities/layout.md
utilities/margin.md
utilities/marketing-borders.md
utilities/marketing-filters.md
utilities/marketing-layout.md
utilities/marketing-margin.md
utilities/marketing-padding.md
utilities/marketing-type.md
Expand Down
1 change: 1 addition & 0 deletions docs/test/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const exceptions = {
'/packages/primer-product': removed,
'/principles/HTML': moved('/principles/html'),
'/principles/SCSS': moved('/principles/scss'),
'/utilities/marketing-layout': moved('/utilities/layout'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually pretty cool: removing primer-marketing-utilities/docs/layout.md caused the /utilities/layout page to disappear, which triggered a failing test. I had to mark that URL as having moved in order to get it passing again.

'/whats_new': redirect('https://github.com/primer/primer/releases'),
'/whats_new/changelog': removed,
'/whats_new/changelog/archived_changelog': removed,
Expand Down
35 changes: 0 additions & 35 deletions modules/primer-marketing-utilities/docs/layout.md

This file was deleted.

1 change: 0 additions & 1 deletion modules/primer-marketing-utilities/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
// utilities
@import "./lib/filters.scss";
@import "./lib/borders.scss";
@import "./lib/layout.scss";
@import "./lib/margin.scss";
@import "./lib/padding.scss";
17 changes: 0 additions & 17 deletions modules/primer-marketing-utilities/lib/layout.scss

This file was deleted.

8 changes: 8 additions & 0 deletions modules/primer-support/lib/variables/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ $responsive-variants: ("": "");
@each $key in map-keys($breakpoints) {
$responsive-variants: map-merge($responsive-variants, ($key: "-#{$key}"));
}

// responive utility position values
$responsive-positions: (
static,
relative,
absolute,
fixed
) !default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up @mdo: I added this variable so that responsive position utilities can be customized. For instance, if you only use relative or absolute positioning, you can do something like:

$responsive-positions: (relative, absolute);
@import "primer-core/index.scss";

And instead of 20 position utilities, you'd get 10.

12 changes: 12 additions & 0 deletions modules/primer-utilities/docs/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,18 @@ _Note: fixed positioning has been disabled here for demonstration only._
</div>
```

### Responsive position

Position utilities can be applied or changed per breakpoint in responsive layouts. Each responsive position utility is applied to the specified breakpoint and up, using the following formula: `position-[breakpoint]-[property]`. For example: `position-md-absolute`.

```html
<div style="height: 64px;">
<div class="border position-md-absolute top-0 right-0">
.position-md-absolute .top-0 .right-0
</div>
</div>
```

### Screen reader only

Use `.sr-only` to position an element outside of the viewport for screen reader access only. **Even though the element can't be seen, make sure it still has a sensible tab order.**
Expand Down
18 changes: 10 additions & 8 deletions modules/primer-utilities/lib/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
// stylelint-disable block-opening-brace-space-after, block-opening-brace-space-before, primer/selector-no-utility
// stylelint-disable comment-empty-line-before

/* Set position to static */
.position-static { position: static !important; }
/* Set position to relative */
.position-relative { position: relative !important; }
/* Set position to absolute */
.position-absolute { position: absolute !important; }
/* Set position to fixed */
.position-fixed { position: fixed !important; }
// Loop through the breakpoint values
@each $breakpoint, $variant in $responsive-variants {
@include breakpoint($breakpoint) {
@each $position in $responsive-positions {
.position#{$variant}-#{$position} {
position: $position !important;
}
}
}
}

/* Set top 0 */
.top-0 { top: 0 !important; }
Expand Down
Loading