Skip to content

Commit

Permalink
♻️ Removed raised-tokens from darkside roles
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh committed Jan 20, 2025
1 parent 7e6d91e commit bbca69a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 35 deletions.
4 changes: 2 additions & 2 deletions @navikt/core/css/darkside/chat.darkside.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@
.navds-chat--info {
& .navds-chat__bubble,
& .navds-chat__avatar {
background-color: var(--ax-bg-info-raised);
background-color: var(--ax-bg-info-moderate);
}
}

.navds-chat--neutral {
& .navds-chat__bubble,
& .navds-chat__avatar {
background-color: var(--ax-bg-raised);
background-color: var(--ax-bg-moderate);
}
}

Expand Down
10 changes: 2 additions & 8 deletions @navikt/core/tokens/darkside/tests/validate-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,13 @@ describe("Validate token configurations", () => {

test(`Semantic tokens for all roles: Lightmode`, () => {
expect(
validateConfig(
semanticTokensForAllRolesConfig("light"),
configKeysWithGroup,
),
validateConfig(semanticTokensForAllRolesConfig(), configKeysWithGroup),
).toBeTruthy();
});

test(`Semantic tokens for all roles: Darkmode`, () => {
expect(
validateConfig(
semanticTokensForAllRolesConfig("dark"),
configKeysWithGroup,
),
validateConfig(semanticTokensForAllRolesConfig(), configKeysWithGroup),
).toBeTruthy();
});

Expand Down
4 changes: 2 additions & 2 deletions @navikt/core/tokens/darkside/tokens.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const lightModeTokens = () => {
mergeConfigs([
shadowTokenConfig("light"),
opacityTokenConfig("light"),
semanticTokensForAllRolesConfig("light"),
semanticTokensForAllRolesConfig(),
textContrastTokenConfig,
semanticTokenConfig("light"),
globalColorLightModeConfig,
Expand All @@ -52,7 +52,7 @@ export const darkModeTokens = () => {
mergeConfigs([
shadowTokenConfig("dark"),
opacityTokenConfig("dark"),
semanticTokensForAllRolesConfig("dark"),
semanticTokensForAllRolesConfig(),
textContrastTokenConfig,
semanticTokenConfig("dark"),
globalColorDarkModeConfig,
Expand Down
23 changes: 4 additions & 19 deletions @navikt/core/tokens/darkside/tokens/semantic-roles.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import _ from "lodash";
import {
ColorRolesList,
type ColorTheme,
type SemanticColorRoles,
} from "../../types";
import { ColorRolesList, type SemanticColorRoles } from "../../types";
import { type StyleDictionaryTokenConfig } from "../tokens.util";

const configForRole = (role: SemanticColorRoles, theme: ColorTheme) => {
const configForRole = (role: SemanticColorRoles) => {
return {
bg: {
[`${role}-soft`]: {
Expand Down Expand Up @@ -69,17 +65,6 @@ const configForRole = (role: SemanticColorRoles, theme: ColorTheme) => {
type: "color",
group: `background.${role}`,
},
[`${role}-raised`]: {
/* We bump raised for darkmode */
value: `{ax.${role}.${theme === "light" ? "100" : "200"}.value}`,
type: "color",
group: `background.${role}`,
},
[`${role}-raised-hover`]: {
value: `{ax.${role}.${theme === "light" ? "200" : "300"}.value}`,
type: "color",
group: `background.${role}`,
},
},
text: {
[role]: {
Expand Down Expand Up @@ -126,9 +111,9 @@ const configForRole = (role: SemanticColorRoles, theme: ColorTheme) => {
/**
* We need to deep merge the token config for each role to get the complete token config for all roles.
*/
export const semanticTokensForAllRolesConfig = (theme: ColorTheme) => {
export const semanticTokensForAllRolesConfig = () => {
return ColorRolesList.filter((name) => name !== "neutral").reduce(
(acc, role) => _.merge(acc, configForRole(role, theme)),
(acc, role) => _.merge(acc, configForRole(role)),
{} as ReturnType<typeof configForRole>,
);
};
6 changes: 2 additions & 4 deletions @navikt/core/tokens/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ export type StaticBgKeys =
| `${SemanticColorRoles}-soft`
| `${SemanticColorRoles}-moderate`
| `${SemanticColorRoles}-moderateA`
| `${SemanticColorRoles}-strong`
| `${SemanticColorRoles}-raised`;
| `${SemanticColorRoles}-strong`;

export type StatefulBgKeys =
| `${SemanticColorRoles}-hover`
Expand All @@ -79,8 +78,7 @@ export type StatefulBgKeys =
| `${SemanticColorRoles}-moderate-pressed`
| `${SemanticColorRoles}-moderate-pressedA`
| `${SemanticColorRoles}-strong-hover`
| `${SemanticColorRoles}-strong-pressed`
| `${SemanticColorRoles}-raised-hover`;
| `${SemanticColorRoles}-strong-pressed`;

export type DefaultTextColorKeys =
| "default"
Expand Down

0 comments on commit bbca69a

Please sign in to comment.