Skip to content

Commit

Permalink
fix: Fixed onSurface to have the correct camel casing (#571)
Browse files Browse the repository at this point in the history
* WIP

* new color doc, fixed onSurface token to camel case

* fix linting errors

* revert concurrency for dev command

* Fixed search input

Lint calls out that I need to pass unnecessary dependencies to the useeffect breaking the input search from working. So removing them again.

* fix title and reorganize

* Fix to Update ThemeTokens.jsx

Had a mispelling on the surface-highest

* Update color.mdx

Spacing adjustment

* Fixed border token

Shame on Brian for not using a token for the border color lol

* Update ColorSamples.jsx to use tokens and theme

* Update ThemeTokens.jsx

* Improving Rendering performance per Art recs.

* Update ColorSamples.jsx

* Resolve conflicting Theme

* Update color.mdx

* Update color.mdx - adjusted spacing

* format and update from main
  • Loading branch information
BrianAA authored Feb 20, 2024
1 parent 870d508 commit 9daca60
Show file tree
Hide file tree
Showing 57 changed files with 1,028 additions and 486 deletions.
10 changes: 2 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

# [1.22.0](https://github.com/washingtonpost/wpds-ui-kit/compare/v1.21.0...v1.22.0) (2024-02-15)


### Bug Fixes

* reverted subtle and faint tokens ([#566](https://github.com/washingtonpost/wpds-ui-kit/issues/566)) ([b45b54a](https://github.com/washingtonpost/wpds-ui-kit/commit/b45b54ab27c3ea341893c79520fe44f3fd463baf))

- reverted subtle and faint tokens ([#566](https://github.com/washingtonpost/wpds-ui-kit/issues/566)) ([b45b54a](https://github.com/washingtonpost/wpds-ui-kit/commit/b45b54ab27c3ea341893c79520fe44f3fd463baf))

### Features

* remove search feature from docs site ([#569](https://github.com/washingtonpost/wpds-ui-kit/issues/569)) ([fa22045](https://github.com/washingtonpost/wpds-ui-kit/commit/fa22045fdb00ba1a823056da0ca24a9d938b3665))




- remove search feature from docs site ([#569](https://github.com/washingtonpost/wpds-ui-kit/issues/569)) ([fa22045](https://github.com/washingtonpost/wpds-ui-kit/commit/fa22045fdb00ba1a823056da0ca24a9d938b3665))

# [1.21.0](https://github.com/washingtonpost/wpds-ui-kit/compare/v1.20.0...v1.21.0) (2024-02-07)

Expand Down
4 changes: 0 additions & 4 deletions apps/vite-project/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package vite-project





# [1.21.0](https://github.com/washingtonpost/wpds-ui-kit/compare/v1.20.0...v1.21.0) (2024-02-07)

**Note:** Version bump only for package vite-project
Expand Down
4 changes: 0 additions & 4 deletions apps/vite-v2-project/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package vite-v2-project





# [1.21.0](https://github.com/washingtonpost/wpds-ui-kit/compare/v1.20.0...v1.21.0) (2024-02-07)

**Note:** Version bump only for package vite-v2-project
Expand Down
7 changes: 1 addition & 6 deletions build.washingtonpost.com/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

# [1.22.0](https://github.com/washingtonpost/wpds-docs/compare/v1.21.0...v1.22.0) (2024-02-15)


### Features

* remove search feature from docs site ([#569](https://github.com/washingtonpost/wpds-docs/issues/569)) ([fa22045](https://github.com/washingtonpost/wpds-docs/commit/fa22045fdb00ba1a823056da0ca24a9d938b3665))




- remove search feature from docs site ([#569](https://github.com/washingtonpost/wpds-docs/issues/569)) ([fa22045](https://github.com/washingtonpost/wpds-docs/commit/fa22045fdb00ba1a823056da0ca24a9d938b3665))

# [1.21.0](https://github.com/washingtonpost/wpds-docs/compare/v1.20.0...v1.21.0) (2024-02-07)

Expand Down
228 changes: 139 additions & 89 deletions build.washingtonpost.com/components/Markdown/Examples/ColorSamples.jsx
Original file line number Diff line number Diff line change
@@ -1,106 +1,156 @@
import React, { useEffect, useState } from "react";
import { Box, styled, AlertBanner, theme } from "@washingtonpost/wpds-ui-kit";
import { toast } from "react-toastify";
import { styled, theme } from "@washingtonpost/wpds-ui-kit";
const uiKit = theme;
import Tokens from "@washingtonpost/wpds-theme/src/wpds.tokens.json";
import { hex, score } from "wcag-contrast";
import { useTheme } from "next-themes";

import { Grid } from "../Components/Grid";
const xMapping = [0, 20, 40, 60, 80, 100, 200, 300, 400, 500, 600, 700];
const yMapping = [
"red",
"blue",
"green",
"orange",
"teal",
"gold",
"mustard",
"purple",
"pink",
"yellow",
"gray",
];

const ColorSamples = ({ group }) => {
const [colorGroupArray, setColorGroupArray] = useState([]);
const [copyText, setCopyText] = useState("");
const PaletteGrid = styled("div", {
display: "grid",
gridTemplateColumns: "30px repeat(12, 1fr)",
gridTemplateRows: "repeat(11, 1fr)", // Adjusted to match yMapping length
gap: "$025",
});

useEffect(() => {
const colorArray = handleColor(group);
setColorGroupArray(colorArray);
}, [group]);
const Swatch = styled("div", {
minWidth: 20,
minHeight: 40,
width: "100%",
height: "100%",
borderRadius: uiKit.radii["012"],
borderColor: uiKit.colors.outline,
borderWidth: "1px",
borderStyle: "solid",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
color: uiKit.colors["gray0"], // Default text color
"@sm": {
minWidth: "unset",
minHeight: "unset",
},
"& div": {
"@sm": {
display: "none",
},
},
});
const AxisLabel = styled("div", {
fontWeight: "bold",
display: "flex",
alignItems: "end",
justifyContent: "center",
});

export default function ColorGrid() {
const { theme } = useTheme();
const [context, setContext] = useState(Tokens.color.light);

useEffect(() => {
const SuccessToast = () => (
<AlertBanner.Root variant="success">
<AlertBanner.Content css={{ minWidth: 250, paddingRight: "$050" }}>
<b>Copied: </b>
<Box as="span" css={{ fontSize: theme.fontSizes[100] }}>
<Box as="i">{copyText}</Box>
</Box>
</AlertBanner.Content>
</AlertBanner.Root>
);
setContext(theme === "dark" ? Tokens.color.dark : Tokens.color.light);
}, [theme]);

if (copyText) {
window.navigator.clipboard.writeText(copyText);
toast(<SuccessToast />, {
position: "top-center",
closeButton: false,
autoClose: 2000,
hideProgressBar: true,
draggable: false,
onClose: () => {
setCopyText(null);
},
});
}
}, [copyText]);
function lookUpValue(item) {
let value = item.value;

const handleColor = (group) => {
const colorNamesArray = Object.keys(Tokens.color[group]);
let lookUpKey = value?.substring(1, value.length - 1);

return colorNamesArray.filter((colorName) =>
Object.prototype.hasOwnProperty.call(
Tokens.color[group][colorName],
"value"
)
);
};
if (theme === "dark") {
value = item.valueDark;
lookUpKey = value?.substring(1, value.length - 1);
return Tokens.color.dark[lookUpKey]?.hex;
} else {
return Tokens.color.light[lookUpKey]?.hex;
}
}

const Swatch = styled("button", {
backgroundColor: "transparent",
border: "1px solid $subtle",
padding: 0,
"&:hover": {
opacity: 0.5,
},
});
const GetSwatchesWithLabels = () => {
let elements = [];
const background = lookUpValue(Tokens.color.theme.background);

// Y-axis labels
yMapping.forEach((label, index) => {
elements.push(
<AxisLabel
key={`y-label-${index}`}
css={{
textTransform: "capitalize",
gridColumn: index + 2,
gridRow: 1,
"@sm": {
display: "none",
},
}}
>
{label}
</AxisLabel>
);
});

const ColorExample = styled("div", {
minHeight: "$500",
width: "100%",
display: "flex",
alignItems: "center",
justifyContent: "center",
});
const ColorID = styled("p", {
fontSize: "$100",
marginBlock: 0,
padding: "$025",
fontFamily: "$meta",
color: "$primary",
});
// X-axis labels
xMapping.forEach((label, index) => {
elements.push(
<AxisLabel
key={`x-label-${index}`}
style={{
justifySelf: "end",
alignSelf: "center",
paddingRight: 4,
gridRow: index + 2,
gridColumn: 1,
}}
>
{label}
</AxisLabel>
);
});

return (
<>
<Grid maxSize={"120px"}>
{colorGroupArray.map((key, i) => (
// Swatches
yMapping.forEach((color, yIndex) => {
xMapping.forEach((_, xIndex) => {
const key = `${color.toLowerCase()}${xMapping[xIndex]}`;
const hexColor = context[key]?.hex || "transparent"; // Use transparent for empty swatches
const contrast =
hexColor != undefined &&
hexColor !== "transparent" &&
hex(hexColor, background).toFixed(2);
const TokenScore = contrast && score(contrast);
elements.push(
<Swatch
key={i}
onClick={() =>
setCopyText(
`$${key.toLowerCase()}${group == "static" ? "-static" : ""}`
)
}
css={{
backgroundColor: `$${key}`,
gridRow: xIndex + 2, // Offset by 1 due to labels
gridColumn: yIndex + 2, // Offset by 1 due to labels
color:
TokenScore && TokenScore !== "AA Large" && TokenScore !== "Fail"
? uiKit.colors.gray700
: uiKit.colors.gray0,
}}
key={key}
>
<ColorExample
css={{
backgroundColor: `$${key}${group == "static" ? "-static" : ""}`,
}}
/>
<ColorID>{key}</ColorID>
<div>{contrast}</div>
</Swatch>
))}
</Grid>
</>
);
};

ColorSamples.displayName = "Color Samples";
);
});
});

export default ColorSamples;
return elements;
};
return <PaletteGrid>{GetSwatchesWithLabels()}</PaletteGrid>;
}
Loading

0 comments on commit 9daca60

Please sign in to comment.