Skip to content
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
3 changes: 2 additions & 1 deletion src/components/Alert/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ Alert.propTypes = {
*/
children: PropTypes.node.isRequired,
/**
* [Color variant](/docs/foundation/colors#component-colors) to clarify importance and meaning of the alert.
* Color variant to clarify importance and meaning of the alert. Implements
* [Feedback and Neutral color collections](/docs/foundation/collections#colors).
*/
color: PropTypes.oneOf(['success', 'warning', 'danger', 'help', 'info', 'note', 'light', 'dark']),
/**
Expand Down
40 changes: 9 additions & 31 deletions src/components/Alert/Alert.module.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@use "sass:map";
@use "../../styles/theme/typography";
@use "../../styles/tools/accessibility";
@use "../../styles/tools/collections";
@use "../../styles/tools/reset";
@use "settings";
@use "theme";
@use "tools";

@layer components.alert {
.root {
Expand Down Expand Up @@ -66,35 +66,13 @@
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);
@each $color in settings.$colors {
@include collections.generate-class(
$prefix: "rui-",
$component-name: "Alert",
$variant-name: "color",
$variant-value: $color,
$properties: settings.$themeable-properties,
);
}
}
11 changes: 6 additions & 5 deletions src/components/Alert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ See [API](#api) for all available options.

## Color Variants

All [component colors](/docs/foundation/colors#component-colors) are supported by
alert to cover all possible needs of your project.
To cover all possible needs of your project, Alert is available in colors from
[Feedback and Neutral color collections](/docs/foundation/collections#colors).

### Success

Expand Down Expand Up @@ -208,9 +208,10 @@ convention looks as follows:

Where:

- `<COLOR>` is one of supported
[component colors](/docs/foundation/colors#component-colors)
(see alert [color variants](#color-variants) and [API](#api)),
- `<COLOR>` is a value from supported
[color collections](/docs/foundation/collections#colors)
(check [color variants](#color-variants) and [API](#api) to see which
collections are supported),
- `<PROPERTY>` is one of `color` (color of text), `foreground-color` (color of
border, icon, links, and emphasis), or `background-color`.

Expand Down
5 changes: 5 additions & 0 deletions src/components/Alert/_settings.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
@use "sass:list";
@use "sass:map";
@use "../../styles/settings/collections";
@use "../../styles/theme/typography";
@use "theme";

$font-size: map.get(typography.$font-size-values, 1);
$line-height: typography.$line-height-base;
$min-height: calc(#{$font-size} * #{$line-height} + 2 * #{theme.$padding});

$colors: list.join(collections.$feedback-colors, collections.$neutral-colors);
$themeable-properties: color, foreground-color, background-color;
43 changes: 0 additions & 43 deletions src/components/Alert/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,3 @@ $border-width: var(--rui-Alert__border-width);
$border-radius: var(--rui-Alert__border-radius);
$emphasis-font-weight: var(--rui-Alert__emphasis__font-weight);
$stripe-width: var(--rui-Alert__stripe__width);

$colors: (
success: (
color: var(--rui-Alert--success__color),
foreground-color: var(--rui-Alert--success__foreground-color),
background-color: var(--rui-Alert--success__background-color),
),
warning: (
color: var(--rui-Alert--warning__color),
foreground-color: var(--rui-Alert--warning__foreground-color),
background-color: var(--rui-Alert--warning__background-color),
),
danger: (
color: var(--rui-Alert--danger__color),
foreground-color: var(--rui-Alert--danger__foreground-color),
background-color: var(--rui-Alert--danger__background-color),
),
info: (
color: var(--rui-Alert--info__color),
foreground-color: var(--rui-Alert--info__foreground-color),
background-color: var(--rui-Alert--info__background-color),
),
help: (
color: var(--rui-Alert--help__color),
foreground-color: var(--rui-Alert--help__foreground-color),
background-color: var(--rui-Alert--help__background-color),
),
note: (
color: var(--rui-Alert--note__color),
foreground-color: var(--rui-Alert--note__foreground-color),
background-color: var(--rui-Alert--note__background-color),
),
light: (
color: var(--rui-Alert--light__color),
foreground-color: var(--rui-Alert--light__foreground-color),
background-color: var(--rui-Alert--light__background-color),
),
dark: (
color: var(--rui-Alert--dark__color),
foreground-color: var(--rui-Alert--dark__foreground-color),
background-color: var(--rui-Alert--dark__background-color),
),
);
10 changes: 0 additions & 10 deletions src/components/Alert/_tools.scss

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/Badge/Badge.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}

@each $color in settings.$colors {
@include collections.generate-properties(
@include collections.generate-class(
$prefix: "rui-",
$component-name: "Badge",
$modifier-name: "priority",
Expand All @@ -51,7 +51,7 @@
}

@each $color in settings.$colors {
@include collections.generate-properties(
@include collections.generate-class(
$prefix: "rui-",
$component-name: "Badge",
$modifier-name: "priority",
Expand Down
3 changes: 2 additions & 1 deletion src/components/Button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ Button.propTypes = {
*/
block: PropTypes.bool,
/**
* [Color variant](/docs/foundation/colors#component-colors) to clarify importance and meaning of the button.
* Color variant to clarify importance and meaning of the alert. Implements
* [Action, Feedback and Neutral color collections](/docs/foundation/collections#colors).
*/
color: PropTypes.oneOf(
['primary', 'secondary', 'selected', 'success', 'warning', 'danger', 'help', 'info', 'note', 'light', 'dark'],
Expand Down
185 changes: 183 additions & 2 deletions src/components/Button/Button.module.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,183 @@
@use "base";
@use "priorities";
// 1. ButtonGroup gap is implemented using the `margin` property so the buttons can overlap and reduce duplicate
// borders.

@use "sass:map";
@use "../../styles/tools/breakpoint";
@use "../../styles/tools/collections";
@use "settings";
@use "theme";
@use "tools";

@layer components.button {
.root {
@include tools.button();
}

.label {
display: block;
}

.beforeLabel,
.afterLabel,
.startCorner,
.endCorner,
.feedbackIcon {
display: flex;
align-items: baseline;
justify-content: center;
}

.startCorner,
.endCorner {
position: absolute;
top: -0.35rem;
z-index: 2;
}

.startCorner {
left: 0;
margin-left: -0.35rem;
}

.endCorner {
right: 0;
margin-right: -0.35rem;
}

.feedbackIcon {
position: absolute;
inset: 0;
z-index: 1;
align-items: center;
}

.isRootSizeSmall {
@include tools.button-size(small);
}

.isRootSizeMedium {
@include tools.button-size(medium);
}

.isRootSizeLarge {
@include tools.button-size(large);
}

.isRootBlock {
width: 100%;
}

.hasRootFeedback:disabled {
opacity: theme.$feedback-opacity;
cursor: theme.$feedback-cursor;
}

.hasRootFeedback .label,
.hasRootFeedback .beforeLabel,
.hasRootFeedback .afterLabel {
color: transparent;
}

.isRootInButtonGroup,
.isRootInInputGroup {
z-index: map.get(settings.$group-z-indexes, button);

&:not(:first-child) {
border-start-start-radius: var(--rui-local-inner-border-radius);
border-end-start-radius: var(--rui-local-inner-border-radius);
}

&:not(:last-child) {
border-start-end-radius: var(--rui-local-inner-border-radius);
border-end-end-radius: var(--rui-local-inner-border-radius);
}
}

.isRootInButtonGroup:not(:first-child) {
margin-inline-start: var(--rui-local-gap); // 1.

&::before {
content: "";
position: absolute;
top: calc(-1 * #{theme.$border-width});
bottom: calc(-1 * #{theme.$border-width});
left: calc(-1 * #{theme.$border-width});
z-index: map.get(settings.$group-z-indexes, separator);
border-left: var(--rui-local-separator-width) solid var(--rui-local-separator-color);
transform: translateX(calc(-0.5 * var(--rui-local-gap) - 50%));
}
}

.isRootInButtonGroup:focus,
.isRootInButtonGroup:not(:disabled):hover {
z-index: map.get(settings.$group-z-indexes, button-hover);
}

.isRootInButtonGroup .startCorner,
.isRootInInputGroup .startCorner,
.isRootInButtonGroup .endCorner,
.isRootInInputGroup .endCorner {
z-index: map.get(settings.$group-z-indexes, button-overflowing-elements);
}

.hasLabelHidden,
.hasLabelVisibleSm,
.hasLabelVisibleMd,
.hasLabelVisibleLg,
.hasLabelVisibleXl,
.hasLabelVisibleX2l,
.hasLabelVisibleX3l {
@include tools.hide-label();
}

.hasLabelVisibleSm {
@include breakpoint.up(sm) {
@include tools.show-label();
}
}

.hasLabelVisibleMd {
@include breakpoint.up(md) {
@include tools.show-label();
}
}

.hasLabelVisibleLg {
@include breakpoint.up(lg) {
@include tools.show-label();
}
}

.hasLabelVisibleXl {
@include breakpoint.up(xl) {
@include tools.show-label();
}
}

.hasLabelVisibleX2l {
@include breakpoint.up(x2l) {
@include tools.show-label();
}
}

.hasLabelVisibleX3l {
@include breakpoint.up(x3l) {
@include tools.show-label();
}
}

@each $priority in map.keys(settings.$themeable-properties) {
@each $color in settings.$colors {
@include collections.generate-class(
$prefix: "rui-",
$component-name: "Button",
$modifier-name: "priority",
$modifier-value: $priority,
$variant-name: "color",
$variant-value: $color,
$generate-interaction-states: true,
$properties: map.get(settings.$themeable-properties, $priority),
);
}
}
}
Loading