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

Inherit link color in components using the Feedback color collection (#492) #565

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 5 additions & 2 deletions src/components/Alert/Alert.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
line-height: settings.$line-height;
}

.message a,
.message strong {
.message :is(a, strong) {
font-weight: theme.$emphasis-font-weight;
}

.message strong {
color: var(--rui-local-foreground-color);
}

Expand All @@ -73,6 +75,7 @@
$variant-name: "color",
$variant-value: $color,
$properties: settings.$themeable-properties,
$inherit-link-color: true,
);
}
}
15 changes: 13 additions & 2 deletions src/components/Alert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Success alerts confirm that an operation has been processed successfully.
```docoff-react-preview
<Alert color="success">
<strong>Success:</strong> Settings have been successfully saved.
{' '}
<TextLink href="/" label="Undo" />
</Alert>
```

Expand All @@ -53,7 +55,7 @@ suggest an action to resolve the problem.
<Alert color="warning">
<strong>Warning:</strong> Your credit card is going to expire soon.
{' '}
<a href="/">Update my payment options</a>
<TextLink href="/" label="Update my payment options" />
</Alert>
```

Expand All @@ -68,7 +70,7 @@ problem.
<strong>Error:</strong> Cannot connect to the server. Is your internet
connection working fine?
{' '}
<a href="/">Try again</a>
<TextLink href="/" label="Try again" />
</Alert>
```

Expand All @@ -80,6 +82,8 @@ This kind of alert can be used to display helpful information.
<Alert color="help">
<strong>Help:</strong> You should choose a password you don&apos;t use
anywhere else.
{' '}
<TextLink href="/" label="Help me choose" />
</Alert>
```

Expand All @@ -90,6 +94,8 @@ Another common, informative alert.
```docoff-react-preview
<Alert color="info">
<strong>Info:</strong> This feature depends on user&apos;s OS preferences.
{' '}
<TextLink href="/" label="Open preferences" />
</Alert>
```

Expand All @@ -100,6 +106,8 @@ Neutral informative alert.
```docoff-react-preview
<Alert>
<strong>Note:</strong> This feature may not be available in all regions.
{' '}
<TextLink href="/" label="Show list of regions" />
</Alert>
```

Expand All @@ -111,6 +119,8 @@ Light alert variant.
<docoff-placeholder dark>
<Alert color="light">
<strong>Light alert:</strong> Stands out on dark backgrounds.
{' '}
<TextLink href="/" label="This is a link" />
</Alert>
</docoff-placeholder>
```
Expand All @@ -122,6 +132,7 @@ Dark alert variant.
```docoff-react-preview
<Alert color="dark">
<strong>Dark alert:</strong> Stands out on light backgrounds.
<TextLink href="/" label="This is a link" />
</Alert>
```

Expand Down
11 changes: 6 additions & 5 deletions src/components/Card/Card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@
box-shadow: theme.$raised-box-shadow;
}

.isRootDisabled {
background-color: theme.$disabled-background-color;
opacity: theme.$disabled-opacity;
}

@each $color in settings.$colors {
@include collections.generate-class(
$prefix: "rui-",
$component-name: "Card",
$variant-name: "color",
$variant-value: $color,
$inherit-link-color: true,
$properties: settings.$themeable-properties,
);
}

.isRootDisabled {
background-color: theme.$disabled-background-color;
opacity: theme.$disabled-opacity;
}
}
22 changes: 22 additions & 0 deletions src/components/Card/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ To cover all possible needs of your project, Card is available in colors from
<Card color="success">
<CardBody>
Hello! I&apos;m success variant of card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" color="success" />
Expand All @@ -162,6 +164,8 @@ To cover all possible needs of your project, Card is available in colors from
<Card color="warning">
<CardBody>
Hello! I&apos;m warning variant of card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" color="warning" />
Expand All @@ -170,6 +174,8 @@ To cover all possible needs of your project, Card is available in colors from
<Card color="danger">
<CardBody>
Hello! I&apos;m danger variant of card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" color="danger" />
Expand All @@ -178,6 +184,8 @@ To cover all possible needs of your project, Card is available in colors from
<Card color="help">
<CardBody>
Hello! I&apos;m help variant of card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" color="help" />
Expand All @@ -186,6 +194,8 @@ To cover all possible needs of your project, Card is available in colors from
<Card color="info">
<CardBody>
Hello! I&apos;m info variant of card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" color="info" />
Expand All @@ -194,6 +204,8 @@ To cover all possible needs of your project, Card is available in colors from
<Card color="note">
<CardBody>
Hello! I&apos;m note variant of card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" color="note" />
Expand All @@ -202,6 +214,8 @@ To cover all possible needs of your project, Card is available in colors from
<Card>
<CardBody>
Hello! I&apos;m light (default) variant of card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" color="dark" />
Expand All @@ -210,6 +224,8 @@ To cover all possible needs of your project, Card is available in colors from
<Card color="dark">
<CardBody>
Hello! I&apos;m dark variant of card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" color="light" />
Expand All @@ -228,6 +244,8 @@ its interactive elements to disallow user's interaction.
<Card disabled>
<CardBody>
Hello! I&apos;m a disabled card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" disabled />
Expand All @@ -236,6 +254,8 @@ its interactive elements to disallow user's interaction.
<Card disabled raised>
<CardBody>
Hello! I&apos;m a disabled raised card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" disabled />
Expand All @@ -244,6 +264,8 @@ its interactive elements to disallow user's interaction.
<Card color="success" disabled>
<CardBody>
Hello! I&apos;m a disabled success variant of card.
{' '}
<TextLink href="/" label="This is a link" />
</CardBody>
<CardFooter>
<Button label="Read more" priority="outline" color="success" disabled />
Expand Down
40 changes: 35 additions & 5 deletions src/components/CheckboxField/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ React.createElement(() => {
return (
<CheckboxField
checked={agree}
label="I agree"
label={(
<>
I have read and agree with
{' '}
<TextLink href="#" label="terms and conditions" />
</>
)}
onChange={() => setAgree(!agree)}
/>
);
Expand Down Expand Up @@ -132,20 +138,44 @@ React.createElement(() => {
<>
<CheckboxField
checked={agree}
label="I have read and agree with terms and conditions"
label={(
<>
I have read and agree with
{' '}
<TextLink href="#" label="terms and conditions" />
</>
)}
onChange={() => setAgree(!agree)}
validationState="valid"
/>
<CheckboxField
checked={agree}
label="I have read and agree with terms and conditions"
label={(
<>
I have read and agree with
{' '}
<TextLink href="#" label="terms and conditions" />
</>
)}
onChange={() => setAgree(!agree)}
validationState="warning"
validationText="Please wait 10 minutes until we verify your data."
validationText={(
<>
Please wait 10 minutes until we verify your data.
{' '}
<TextLink href="#" label="Cancel" />
</>
)}
/>
<CheckboxField
checked={agree}
label="I have read and agree with terms and conditions"
label={(
<>
I have read and agree with
{' '}
<TextLink href="#" label="terms and conditions" />
</>
)}
onChange={() => setAgree(!agree)}
required
validationState="invalid"
Expand Down
16 changes: 14 additions & 2 deletions src/components/TextField/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,13 @@ have.
label="User name"
onChange={() => {}}
validationState="warning"
validationText="Account with this name already exists, pick a different one."
validationText={(
<>
Account with this name already exists, pick a different one.
{' '}
<TextLink href="#" label="Forgot your password?" />
</>
)}
value="joe"
required
/>
Expand All @@ -411,7 +417,13 @@ have.
label="User name"
onChange={() => {}}
validationState="warning"
validationText="Account with this name already exists, pick a different one."
validationText={(
<>
Account with this name already exists, pick a different one.
{' '}
<TextLink href="#" label="Forgot your password?" />
</>
)}
variant="filled"
value="joe"
required
Expand Down
13 changes: 10 additions & 3 deletions src/components/TextLink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ helps to improve its accessibility.

## Theming

ℹ️ The TextLink component is context-aware and can inherit text color from its
parent component. This applies for components using
[Feedback color collection](/docs/foundation/collections#colors) and for
components in any of the supported
[validation states](/docs/foundation/colors#validation-states).
adamkudrna marked this conversation as resolved.
Show resolved Hide resolved
In such cases, the custom properties marked with an asterisk (\*) are ignored.

| Custom Property | Description |
|-------------------------------------------|-------------------------------------|
| `--rui-TextLink__color` | Text color |
| `--rui-TextLink__color` \* | Text color |
| `--rui-TextLink__text-decoration` | Text decoration, e.g. underline |
| `--rui-TextLink--hover__color` | Text color on hover |
| `--rui-TextLink--hover__color` \* | Text color on hover |
| `--rui-TextLink--hover__text-decoration` | Text decoration on hover |
| `--rui-TextLink--active__color` | Text color in the active state |
| `--rui-TextLink--active__color` \* | Text color in the active state |
| `--rui-TextLink--active__text-decoration` | Text decoration in the active state |

[a-attributes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes
Expand Down
6 changes: 3 additions & 3 deletions src/components/TextLink/_theme.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$color: var(--rui-TextLink__color);
$color: var(--rui-local-link-color, var(--rui-TextLink__color));
$text-decoration: var(--rui-TextLink__text-decoration);
$hover-color: var(--rui-TextLink--hover__color);
$hover-color: var(--rui-local-link-color-hover, var(--rui-TextLink--hover__color));
$hover-text-decoration: var(--rui-TextLink--hover__text-decoration);
$active-color: var(--rui-TextLink--active__color);
$active-color: var(--rui-local-link-color-active, var(--rui-TextLink--active__color));
$active-text-decoration: var(--rui-TextLink--active__text-decoration);
10 changes: 9 additions & 1 deletion src/components/Toggle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,15 @@ React.createElement(() => {
label="Listen in studio quality"
onChange={() => setStudioQuality(!studioQuality)}
validationState="invalid"
validationText="Please upgrade your plan to make this option available."
validationText={(
<>
Please
{' '}
<TextLink href="#" label="upgrade your plan" />
{' '}
to make this option available.
</>
)}
/>
</>
);
Expand Down
8 changes: 6 additions & 2 deletions src/styles/elements/_links.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ a {
text-decoration: links.$decoration;
color: links.$color;

&:hover,
&:focus {
&:hover {
text-decoration: links.$hover-decoration;
color: links.$hover-color;
}

&:active {
text-decoration: links.$active-decoration;
color: links.$active-color;
}
}
Loading