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

Leverage CSS cascade layers to fix and user-proof styles order #529

Merged
merged 3 commits into from
Mar 27, 2024
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
54 changes: 32 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"babel-jest": "^29.6.4",
"babel-loader": "^9.1.3",
"core-js": "^3.32.1",
"css-loader": "^6.8.1",
"css-loader": "^6.10.0",
"eslint": "^8.48.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.28.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Alert/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { transferProps } from '../_helpers/transferProps';
import { classNames } from '../../utils/classNames';
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
import styles from './Alert.scss';
import styles from './Alert.module.scss';

export const Alert = ({
children,
Expand Down
100 changes: 100 additions & 0 deletions src/components/Alert/Alert.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
@use "sass:map";
@use "../../styles/theme/typography";
@use "../../styles/tools/accessibility";
@use "../../styles/tools/reset";
@use "settings";
@use "theme";
@use "tools";

@layer components.alert {
.root {
position: relative;
display: flex;
align-items: flex-start;
width: 100%;
color: var(--rui-local-color);
border-width: theme.$border-width theme.$border-width theme.$border-width theme.$stripe-width;
border-style: solid;
border-color: var(--rui-local-foreground-color);
border-radius: theme.$border-radius;
background-color: var(--rui-local-background-color);
}

.icon,
.message {
padding: theme.$padding;
}

.close,
.icon {
height: settings.$min-height;
color: var(--rui-local-foreground-color);
}

.icon {
display: flex;
flex: none;
align-items: center;
justify-content: center;
padding-right: 0;
}

.message {
flex-grow: 1;
font-weight: theme.$font-weight;
font-size: settings.$font-size;
line-height: settings.$line-height;
}

.message a,
.message strong {
font-weight: theme.$emphasis-font-weight;
color: var(--rui-local-foreground-color);
}

.close {
@include reset.button();
@include accessibility.min-tap-target();

padding: theme.$padding;
font-size: map.get(typography.$font-size-values, 4);
line-height: 1;
}

.closeSign {
position: relative;
top: -0.1em;
}

.isRootColorSuccess {
@include tools.color(success);
}

.isRootColorWarning {
@include tools.color(warning);
}

.isRootColorDanger {
@include tools.color(danger);
}

.isRootColorHelp {
@include tools.color(help);
}

.isRootColorInfo {
@include tools.color(info);
}

.isRootColorNote {
@include tools.color(note);
}

.isRootColorLight {
@include tools.color(light);
}

.isRootColorDark {
@include tools.color(dark);
}
}
98 changes: 0 additions & 98 deletions src/components/Alert/Alert.scss

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/Badge/Badge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { withGlobalProps } from '../../provider';
import { transferProps } from '../_helpers/transferProps';
import { classNames } from '../../utils/classNames';
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
import styles from './Badge.scss';
import styles from './Badge.module.scss';

export const Badge = ({
color,
Expand Down
Loading
Loading