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

Fix a couple issues with anchor styling #1972

Merged
merged 11 commits into from
Apr 10, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
m-akinc marked this conversation as resolved.
Show resolved Hide resolved
"type": "patch",
"comment": "Fix a couple issues with anchor styling",
"packageName": "@ni/nimble-components",
"email": "7282195+m-akinc@users.noreply.github.com",
"dependentChangeType": "patch"
}
129 changes: 60 additions & 69 deletions packages/nimble-components/src/anchor/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,102 +2,93 @@ import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { focusVisible } from '../utilities/style/focus';
import {
linkActiveDisabledFontColor,
linkActiveFontColor,
linkActiveProminentFontColor,
linkDisabledFontColor,
linkFont,
linkFontColor,
linkProminentDisabledFontColor,
linkProminentFontColor
} from '../theme-provider/design-tokens';

export const styles = css`
${display('inline')}
@layer base, hover, focusVisible, active, disabled;
m-akinc marked this conversation as resolved.
Show resolved Hide resolved

:host {
box-sizing: border-box;
font: ${linkFont};
}

.top-container {
display: contents;
}

[part='start'] {
display: none;
}

.control {
color: ${linkFontColor};
text-decoration: underline;
}

.control${focusVisible} {
display: inline;
outline: none;
box-shadow: inset 0px -1px ${linkFontColor};
}

.control:active {
color: ${linkActiveFontColor};
text-decoration: underline;
}
@layer base {
${display('inline')}

.control${focusVisible}:active {
box-shadow: inset 0px -1px ${linkActiveFontColor};
}
:host {
box-sizing: border-box;
font: ${linkFont};
}

.control:not(:any-link) {
color: ${linkDisabledFontColor};
text-decoration: none;
}
.top-container {
display: contents;
}

.control:not(:any-link):active {
color: ${linkActiveDisabledFontColor};
}
[part='start'] {
m-akinc marked this conversation as resolved.
Show resolved Hide resolved
display: none;
}

:host([underline-hidden]) .control {
text-decoration: none;
}
.control {
color: ${linkFontColor};
text-decoration: underline;
}

:host([underline-hidden]) .control:hover {
text-decoration: underline;
}
:host([underline-hidden]) .control {
text-decoration: none;
}

:host([underline-hidden]) .control${focusVisible} {
text-decoration: underline;
}
:host([appearance='prominent']) .control {
color: ${linkProminentFontColor};
}

:host([underline-hidden]) .control:not(:any-link) {
text-decoration: none;
}
.content {
pointer-events: none;
}

:host([appearance='prominent']) .control {
color: ${linkProminentFontColor};
[part='end'] {
display: none;
}
}

:host([appearance='prominent']) .control:active {
color: ${linkActiveProminentFontColor};
@layer hover {
.control:any-link:hover {
text-decoration: underline;
}
}

:host([appearance='prominent']) .control${focusVisible} {
box-shadow: inset 0px -1px ${linkProminentFontColor};
@layer focusVisible {
.control${focusVisible} {
outline: none;
box-shadow: inset 0px -1px;
text-decoration: underline;
}
}

:host([appearance='prominent']) .control${focusVisible}:active {
box-shadow: inset 0px -1px ${linkActiveProminentFontColor};
}
@layer active {
.control:active {
color: ${linkActiveFontColor};
text-decoration: underline;
box-shadow: none;
}

:host([appearance='prominent']) .control:not(:any-link) {
color: ${linkProminentDisabledFontColor};
}
:host([appearance='prominent']) .control:active {
color: ${linkActiveProminentFontColor};
}

.content {
pointer-events: none;
${
'' /* It's probably cleaner to add :not(active) to the selector in the 'active' layer (rather
m-akinc marked this conversation as resolved.
Show resolved Hide resolved
than resetting text-decoration back to the value from the 'default' layer), but
there's a bug in storybook-addon-pseudo-states where it doesn't handle :not() properly. */
}
:host([underline-hidden]) .control:active {
text-decoration: none;
}
}

[part='end'] {
display: none;
@layer disabled {
.control:not(:any-link) {
color: ${linkDisabledFontColor};
}
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ export const [
element,
DigitalGreenLight,
DigitalGreenLight,
PowerGreen
hexToRgbaCssColor(White, 0.6)
m-akinc marked this conversation as resolved.
Show resolved Hide resolved
),
(element: HTMLElement) => hexToRgbaCssColor(getDefaultFontColorForTheme(element), 0.3),
LinkLightUiFamily,
Expand Down
Loading