Skip to content

Merge CSS helpers and utilities into single SCSS endpoint to make their use easier #161

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

Merged
merged 1 commit into from
Oct 3, 2020
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ To use React UI in your app:
import '@react-ui-org/react-ui/src/lib/theme.scss';
import '@react-ui-org/react-ui/src/lib/foundation.scss';
import '@react-ui-org/react-ui/src/lib/helpers.scss';
import '@react-ui-org/react-ui/src/lib/utilities.scss';
```

6. Finally, use React UI **components** just like you are used to:
Expand Down
3 changes: 0 additions & 3 deletions src/demo/pages/DemoContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ import {
Swatch,
} from '../components';

// React UI utility CSS classes
import '../../lib/utilities.scss';

import navigationTree from './navigation';

const logger = (event) => console.log(event.target.value); // eslint-disable-line no-console
Expand Down
2 changes: 1 addition & 1 deletion src/lib/foundation.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Basic themeable CSS layer to prepare ground for components.
// Mandatory themeable CSS layer to prepare ground for components.
// Structured according to ITCSS methodology, ie. most importantly in ascending specificity.

//
Expand Down
38 changes: 18 additions & 20 deletions src/lib/helpers.scss
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
// General purpose helpers for common situations. Unlike utilities, helpers usually cover more CSS
// properties than one. And unlike with utilities, using `!important` is not allowed here.
// Optional layer with helper CSS classes to easily adjust visual details.
// Structured according to ITCSS methodology, ie. most importantly in ascending specificity.
// This file should be imported as the very last of your stylesheets.

$_spin-count: 4;
$_spin-duration: 2.2s;
$_spin-easing: cubic-bezier(0.31, 0.3, 0.34, -0.17);
//
// 1. Helpers
// ==========
//
// General purpose helpers for common situations. They can compose multiple CSS rules to do a bit
// more complicated tasks.

@keyframes spin {
0% {
transform: rotate(0 * 360deg);
}
@import 'styles/helpers/animation';

100% {
transform: rotate($_spin-count * 360deg);
}
}
//
// 2. Utilities
// ============
//
// Utility classes to tweak small details like typography, margins or padding. They do just one
// thing: they set a single CSS rule and use the otherwise disallowed `!important` to enforce it.
// Also they are often responsive (can be adjusted for individual breakpoints).

:global(.animation-spin-clockwise) {
animation: spin $_spin-duration $_spin-easing infinite;
}

:global(.animation-spin-counterclockwise) {
animation: spin $_spin-duration $_spin-easing infinite reverse;
}
@import 'styles/utilities';
10 changes: 4 additions & 6 deletions src/lib/utilities.scss → src/lib/styles/_utilities.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Responsive utility classes to tweak small details like typography, margins or padding.

@import 'styles/settings/breakpoints';
@import 'styles/settings/utilities';
@import 'styles/tools/breakpoints';
@import 'styles/tools/utilities';
@import 'settings/breakpoints';
@import 'settings/utilities';
@import 'tools/breakpoints';
@import 'tools/utilities';

@each $breakpoint in map-keys($breakpoint-values) {
@include breakpoint-up($breakpoint) {
Expand Down
21 changes: 21 additions & 0 deletions src/lib/styles/helpers/_animation.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$_spin-count: 4;
$_spin-duration: 2.2s;
$_spin-easing: cubic-bezier(0.31, 0.3, 0.34, -0.17);

@keyframes spin {
0% {
transform: rotate(0 * 360deg);
}

100% {
transform: rotate($_spin-count * 360deg);
}
}

:global(.animation-spin-clockwise) {
animation: spin $_spin-duration $_spin-easing infinite;
}

:global(.animation-spin-counterclockwise) {
animation: spin $_spin-duration $_spin-easing infinite reverse;
}