Skip to content

Commit

Permalink
Fixed link style generating light and dark modes together (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
origami-z authored Sep 3, 2024
1 parent 6a9ee3e commit bb1189a
Show file tree
Hide file tree
Showing 20 changed files with 239 additions and 120 deletions.
7 changes: 7 additions & 0 deletions .changeset/weak-tigers-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@jpmorganchase/mosaic-content-editor-plugin': patch
'@jpmorganchase/mosaic-site': patch
'@jpmorganchase/mosaic-theme': patch
---

Fixed link style CSS is generated against both light and dark modes. Fixed #640.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { lightModeConditions, vars } from '@jpmorganchase/mosaic-theme';
import { bothModeConditions, vars } from '@jpmorganchase/mosaic-theme';
import { defineProperties, createSprinkles } from '@vanilla-extract/sprinkles';

export const outlineProperties = defineProperties({
conditions: {
...lightModeConditions
...bothModeConditions
},
defaultCondition: 'lightMode',
properties: {
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/border/border.css.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineProperties, createSprinkles } from '@vanilla-extract/sprinkles';
import { darkMode, lightMode } from '../color/lightMode';
import { darkMode, lightMode } from '../color/modes';

import { vars } from '../vars.css';

Expand Down
8 changes: 4 additions & 4 deletions packages/theme/src/color/actionable.css.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defineProperties, createSprinkles } from '@vanilla-extract/sprinkles';
import { recipe, RecipeVariants } from '@vanilla-extract/recipes';
import { vars } from '../vars.css';
import { darkMode, lightMode, lightModeConditions } from './lightMode';
import { darkMode, lightMode, bothModeConditions } from './modes';

export const ctaColorProperties = defineProperties({
conditions: {
...lightModeConditions,
...bothModeConditions,
lightModeHover: { selector: `${lightMode} &:hover` },
darkModeHover: { selector: `${darkMode} &:hover` },
lightModeActive: { selector: `${lightMode} &:active` },
Expand Down Expand Up @@ -63,7 +63,7 @@ export type CtaColorVariants = RecipeVariants<typeof ctaColor>;

export const primaryColorProperties = defineProperties({
conditions: {
...lightModeConditions,
...bothModeConditions,
lightModeHover: { selector: `${lightMode} &:hover` },
darkModeHover: { selector: `${darkMode} &:hover` },
lightModeActive: { selector: `${lightMode} &:active` },
Expand Down Expand Up @@ -120,7 +120,7 @@ export type PrimaryColorVariants = RecipeVariants<typeof primaryColor>;

export const secondaryColorProperties = defineProperties({
conditions: {
...lightModeConditions,
...bothModeConditions,
lightModeHover: { selector: `${lightMode} &:hover` },
darkModeHover: { selector: `${darkMode} &:hover` },
lightModeActive: { selector: `${lightMode} &:active` },
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/color/beforeElement.css.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineProperties, createSprinkles } from '@vanilla-extract/sprinkles';

import { vars } from '../vars.css';
import { darkMode, lightMode } from './lightMode';
import { darkMode, lightMode } from './modes';

export const beforeElementColorProperties = defineProperties({
conditions: {
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/src/color/brand.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { defineProperties, createSprinkles } from '@vanilla-extract/sprinkles';
import { recipe, RecipeVariants } from '@vanilla-extract/recipes';

import { vars } from '../vars.css';
import { lightModeConditions } from './lightMode';
import { bothModeConditions } from './modes';

export const brandColorProperties = defineProperties({
conditions: lightModeConditions,
conditions: bothModeConditions,
defaultCondition: ['lightMode', 'darkMode'],
properties: {
color: [...Object.values(vars.color.light.brand), ...Object.values(vars.color.dark.brand)],
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/src/color/callout.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { defineProperties, createSprinkles } from '@vanilla-extract/sprinkles';
import { recipe, RecipeVariants } from '@vanilla-extract/recipes';

import { vars } from '../vars.css';
import { lightModeConditions } from './lightMode';
import { bothModeConditions } from './modes';

export const calloutColorProperties = defineProperties({
conditions: lightModeConditions,
conditions: bothModeConditions,
defaultCondition: ['lightMode', 'darkMode'],
properties: {
backgroundColor: [
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/color/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export * from './navigable.css';
export * from './neutral.css';
export * from './selectable.css';
export * from './status.css';
export * from './lightMode';
export * from './modes';
7 changes: 0 additions & 7 deletions packages/theme/src/color/lightMode.ts

This file was deleted.

30 changes: 30 additions & 0 deletions packages/theme/src/color/modes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export const lightMode = '[data-mode="light"]';
export const darkMode = '[data-mode="dark"]';

export const lightModeCondition = {
lightMode: { selector: `${lightMode} &` }
};
export const lightModeInteractiveCondition = {
...lightModeCondition,
lightModeHover: { selector: `${lightMode} &:hover, ${lightMode} &[data-dp-hover="true"]` },
lightModeActive: { selector: `${lightMode} &:active` },
lightModeDisabled: { selector: `${lightMode} &:disabled` }
};
export const darkModeCondition = {
darkMode: { selector: `${darkMode} &` }
};
export const darkModeInteractiveCondition = {
...darkModeCondition,
darkModeHover: { selector: `${darkMode} &:hover` },
darkModeActive: { selector: `${darkMode} &:active` },
darkModeDisabled: { selector: `${darkMode} &:disabled` }
};

/**
* Both modes conditions, use with caution.
* All properties will be generated against both modes, if you use with `defineProperties`.
* */
export const bothModeConditions = {
...lightModeCondition,
...darkModeCondition
};
Loading

0 comments on commit bb1189a

Please sign in to comment.