diff --git a/CHANGELOG.md b/CHANGELOG.md index 589bf7d..55f1d51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,35 @@ # Changelog +## 2.7.0 + +### Changed: the primary colour is blue (PROD-2966) + +The primary colour changes from purple to blue-600 (`#1A56DB`). This is a visible change for every +consumer. + +- **Primary buttons** (`Button`, `Capsule`, `ButtonDropdown`): fill `primary-600`, hover + `primary-700`, pressed `primary-800`, disabled `primary-300`. The loader spinner is `primary-600`. +- **Secondary buttons**: `primary-50` fill, `primary-400` border, `primary-700` text, `primary-100` + hover. +- **Checked and selected states** (`Checkbox`, `Radio`, `ToggleSwitch`, `ComboBox` options): + `primary-600`. +- **Focus**: blue-600 everywhere. Rings are `primary-600` (`Radio` was `purple-500`), and text + inputs, selects and comboboxes focus with a `primary-600` border. `TextArea` now focuses with a + single border and no ring, like the other inputs. +- `Badge` with `color="primary"` is blue. `color="secondary"` stays violet. + +### Added: `primary-*` as CSS variables, and a Tailwind preset (PROD-2967) + +- `primary-50` to `primary-950` are now CSS variables (`--primary-*`) in `dist/tailwind.css`, and + components use `primary-*` instead of raw `purple-*` and `violet-*` classes. `primary-50` was a + grey and `primary-950` didn't exist. +- The theme now lives in `tailwind.preset.js`, exported as `@agility/plenum-ui/tailwind.preset`, so + a consumer's own classes match Plenum's. See "Colours" in the README. + +### Fixed: `blue-300` + +`blue-300` was `#8FB2`, which browsers read as a nearly transparent green. It is now `#8FB2FB`. + ## 2.6.3 ### Fixed: `TextArea` placeholder colour diff --git a/README.md b/README.md index da60f3a..d66e27e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,24 @@ import "@agility/plenum-ui/dist/lib/tailwind.css" Make sure to add any additional styles before these two import statements to prevent overwriting the Plenum styling. +## Colours + +The primary colour is blue-600 (`#1A56DB`). Its scale, `primary-50` to `primary-950`, is a set of CSS +variables (`--primary-50` … `--primary-950`) defined in `dist/tailwind.css`. Components use `primary-*` +for anything that means "primary" (buttons, focus, checked and selected states), never a palette name +such as `blue-*` or `purple-*`, so a future colour change is an edit to the preset, not to every +component. + +To build your own Tailwind classes with the same colours, load Plenum's preset in your +`tailwind.config.js`: + +```js +module.exports = { + presets: [require("@agility/plenum-ui/tailwind.preset")], + content: ["./src/**/*.{js,ts,jsx,tsx}"] +} +``` + ## Installation You can install the Plenum library using npm or yarn: diff --git a/app/globals.css b/app/globals.css index 54479ff..1b04d5d 100644 --- a/app/globals.css +++ b/app/globals.css @@ -5,7 +5,7 @@ @layer { * { /* set the default outline color on focus */ - outline-color: #7933dd; + outline-color: rgb(var(--primary-600)); } /* Thin - 100 */ @font-face { diff --git a/package.json b/package.json index fcaf422..f2b2d6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@agility/plenum-ui", - "version": "2.6.3", + "version": "2.7.0", "license": "MIT", "main": "dist/index.js", "module": "dist/index.js", diff --git a/stories/atoms/badges/Badge.tsx b/stories/atoms/badges/Badge.tsx index be8246e..be89b9c 100644 --- a/stories/atoms/badges/Badge.tsx +++ b/stories/atoms/badges/Badge.tsx @@ -31,7 +31,7 @@ const Badge: React.FC = ({ actionButton }) => { const badgeStyles = cn( - "text-sm flex items-center py-[2px] focus:ring-1 focus:ring-purple-600 outline-0", + "text-sm flex items-center py-[2px] focus:ring-1 focus:ring-primary-600 outline-0", { "rounded-[3px]": variant === "rounded", "rounded-full px-[6px]": variant === "pill", @@ -43,7 +43,7 @@ const Badge: React.FC = ({ "pr-3": !removeButton && size === "lg", "pr-[10px]": !removeButton && size === "sm", "gap-x-[6px]": statusDot || removeButton || loading, - "bg-purple-100 text-purple-800 ": color === "primary", + "bg-primary-100 text-primary-800 ": color === "primary", "bg-violet-100 text-violet-800": color === "secondary", "bg-pink-100 text-pink-800": color === "pink", "bg-red-100 text-red-800": color === "danger", @@ -54,7 +54,7 @@ const Badge: React.FC = ({ } ) const statusDotStyles = cn("rounded-full h-[6px] p-[1px] w-[6px]", { - "bg-purple-400 text-purple-400": color === "primary", + "bg-primary-400 text-primary-400": color === "primary", "bg-violet-400 text-violet-400": color === "secondary", "bg-pink-400 text-pink-400": color === "pink", "bg-red-400 text-red-400": color === "danger", @@ -64,9 +64,9 @@ const Badge: React.FC = ({ "bg-gray-400 text-gray-400": color === "basic" }) const removeButtonStyles: ClassNameWithAutocomplete = cn( - "h-4 w-4 group-focus-within:ring-1 group-focus-within:ring-purple-600 rounded-full outline-0", + "h-4 w-4 group-focus-within:ring-1 group-focus-within:ring-primary-600 rounded-full outline-0", { - "text-purple-400": color === "primary", + "text-primary-400": color === "primary", "text-violet-400": color === "secondary", "text-pink-400": color === "pink", "text-red-400": color === "danger", @@ -78,7 +78,7 @@ const Badge: React.FC = ({ ) const loaderStyles = cn("h-4 w-4 rounded-full border-2 animate-spin", { - "border-purple-400 !border-r-purple-200": color === "primary", + "border-primary-400 !border-r-primary-200": color === "primary", "border-violet-400 !border-r-violet-200": color === "secondary", "border-pink-400 !border-r-pink-200": color === "pink", "border-red-400 !border-r-red-200": color === "danger", diff --git a/stories/atoms/buttons/Button/Button.tsx b/stories/atoms/buttons/Button/Button.tsx index 26290c1..14587fd 100644 --- a/stories/atoms/buttons/Button/Button.tsx +++ b/stories/atoms/buttons/Button/Button.tsx @@ -62,7 +62,7 @@ const _Button = ( const applyMinWidth = !!label && size !== "xs" && size !== "sm"; let iconStyles = cn( { "text-white h-5 w-5 stroke-[1.5]": actionType === "primary" || actionType === "danger" }, - { "text-purple-700 h-5 w-5 stroke-[1.5]": actionType === "secondary" }, + { "text-primary-700 h-5 w-5 stroke-[1.5]": actionType === "secondary" }, { "text-gray-400 h-5 w-5 stroke-[1.5]": actionType === "alternative" }, { "text-transparent-black-40 h-5 w-5 stroke-[1.5]": actionType === "warning" } ); @@ -73,7 +73,7 @@ const _Button = ( const loaderColors = cn( { "border-r-white": actionType === "primary" }, - { "border-purple-200 border-r-purple-700": actionType === "secondary" }, + { "border-primary-200 border-r-primary-700": actionType === "secondary" }, { "border-gray-200 border-r-gray-700": actionType === "alternative" }, { "border-red-800 border-r-white": actionType === "danger" }, { "border-yellow-800 border-r-transparent-black-70": actionType === "warning" } @@ -93,7 +93,7 @@ const _Button = ( title: asLink.title, className: twMerge( cn( - "inline-flex items-center justify-center gap-x-2 font rounded-[3px] outline-none focus-visible:ring-1 focus-visible:ring-purple-600 transition-all", + "inline-flex items-center justify-center gap-x-2 font rounded-[3px] outline-none focus-visible:ring-1 focus-visible:ring-primary-600 transition-all", { "min-w-[130px]": applyMinWidth }, { "w-full": fullWidth }, { "px-[11px] py-[7px] text-xs": resolvedSize === "xs" }, @@ -102,11 +102,11 @@ const _Button = ( { "px-[17px] py-[9px] text-base": resolvedSize === "lg" }, { "px-[25px] py-[13px] text-base": resolvedSize === "xl" }, { - "bg-violet-800 text-white focus-visible:ring-offset-1 focus-visible:ring-offset-white hover:border-violet-700 hover:bg-violet-700 disabled:bg-violet-400 disabled:hover:bg-violet-400 disabled:focus-visible:ring-0": + "bg-primary-600 text-white focus-visible:ring-offset-1 focus-visible:ring-offset-white hover:border-primary-700 hover:bg-primary-700 disabled:bg-primary-300 disabled:hover:bg-primary-300 disabled:focus-visible:ring-0": actionType === "primary" }, { - " bg-purple-50 border-purple-400 border hover:border-purple-500 text-purple-700 hover:bg-purple-100 focus-within:bg-purple-100 focus-visible:bg-purple-100 focus:bg-purple-100 active:bg-purple-100 disabled:bg-purple-50 disabled:hover:bg-purple-50 disabled:text-purple-300 disabled:focus-visible:ring-0": + " bg-primary-50 border-primary-400 border hover:border-primary-500 text-primary-700 hover:bg-primary-100 focus-within:bg-primary-100 focus-visible:bg-primary-100 focus:bg-primary-100 active:bg-primary-100 disabled:bg-primary-50 disabled:hover:bg-primary-50 disabled:text-primary-300 disabled:focus-visible:ring-0": actionType === "secondary" }, { @@ -176,7 +176,7 @@ const _Button = ( type="button" className={twMerge( cn( - " px-4 py-2 inline-flex items-center justify-center gap-x-2 rounded outline-none focus-visible:ring-1 focus-visible:ring-purple-600 transition-all h-9", + " px-4 py-2 inline-flex items-center justify-center gap-x-2 rounded outline-none focus-visible:ring-1 focus-visible:ring-primary-600 transition-all h-9", { "min-w-[130px]": applyMinWidth }, { "w-full": fullWidth }, { "text-xs": resolvedSize === "xs" }, @@ -185,11 +185,11 @@ const _Button = ( { "text-base": resolvedSize === "lg" }, { "text-base": resolvedSize === "xl" }, { - "bg-violet-800 text-white focus-visible:ring-offset-1 focus-visible:ring-offset-white hover:border-violet-700 hover:bg-violet-700 disabled:bg-violet-400 disabled:hover:bg-violet-400 disabled:focus-visible:ring-0": + "bg-primary-600 text-white focus-visible:ring-offset-1 focus-visible:ring-offset-white hover:border-primary-700 hover:bg-primary-700 disabled:bg-primary-300 disabled:hover:bg-primary-300 disabled:focus-visible:ring-0": actionType === "primary" }, { - " bg-purple-50 border-purple-400 border hover:border-purple-500 text-purple-700 hover:bg-purple-100 focus-within:bg-purple-100 focus-visible:bg-purple-100 focus:bg-purple-100 active:bg-purple-100 disabled:bg-purple-50 disabled:hover:bg-purple-50 disabled:text-purple-300 disabled:focus-visible:ring-0": + " bg-primary-50 border-primary-400 border hover:border-primary-500 text-primary-700 hover:bg-primary-100 focus-within:bg-primary-100 focus-visible:bg-primary-100 focus:bg-primary-100 active:bg-primary-100 disabled:bg-primary-50 disabled:hover:bg-primary-50 disabled:text-primary-300 disabled:focus-visible:ring-0": actionType === "secondary" }, { diff --git a/stories/atoms/buttons/Button/tests/Button.test.tsx b/stories/atoms/buttons/Button/tests/Button.test.tsx index bae84ea..d494fb2 100644 --- a/stories/atoms/buttons/Button/tests/Button.test.tsx +++ b/stories/atoms/buttons/Button/tests/Button.test.tsx @@ -19,14 +19,14 @@ describe("