Skip to content

Commit

Permalink
Define layerStyles for ease of use downstream (#202)
Browse files Browse the repository at this point in the history
* feat(layer-styles): add base for layer styles in aniref preset

* chore: add 950 for brand.secondary color palette

* chore: add TODO comment for layerStyles

* ci(changeset): add changeset for layerStyles addition

* chore: remove unnecessary comment

* chore: add TODO comment for layerStyles

* refactor: update layerStyles and Button recipe

* ci(changesets): add changeset for button recipe update

* chore: remove unnecessary button layer style from preset

* chore: remove incorrect TODO comment about layer style implementation

* feat: add accent gradient to layer styles

* ci(changesets): add changeset for banner recipe update

* chore: update layer style naming conventions

* fix: update descriptions for layer styles

* chore: update layer style naming conventions

* fix(Button): update recipe for ghost variant disabled styles

* chore(Banner): remove unnecessary variants from recipe

* build(deps): update framer-motion dep
  • Loading branch information
hobbescodes authored Jan 3, 2024
1 parent d448429 commit 5dcc96e
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-bobcats-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@animareflection/ui": minor
---

Defined `layerStyles` in aniref preset to allow for prop use downstream
5 changes: 5 additions & 0 deletions .changeset/friendly-windows-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@animareflection/ui": patch
---

Updated `Button` recipe styles for consistent sizing across variants
5 changes: 5 additions & 0 deletions .changeset/ten-coins-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@animareflection/ui": patch
---

Remove variants from `Banner` recipe in favor of `defaultGradient` layer style
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"eslint-plugin-testing-library": "^6.2.0",
"eslint-plugin-typescript-sort-keys": "^3.1.0",
"eslint-plugin-unused-imports": "^3.0.0",
"framer-motion": "^10.16.16",
"framer-motion": "^10.17.4",
"http-server": "^14.1.1",
"husky": "^8.0.3",
"jsonfile": "^6.1.0",
Expand Down
9 changes: 0 additions & 9 deletions src/components/core/Banner/Banner.recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,4 @@ export const bannerRecipe = defineRecipe({
background: "accent.default",
color: "accent.fg",
},
variants: {
variant: {
gradient: {
bgGradient: "to-r",
gradientFrom: "brand.secondary.500",
gradientTo: "accent.default",
},
},
},
});
4 changes: 2 additions & 2 deletions src/components/core/Banner/Banner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const Closeable: Story = {
export const Gradient: Story = {
render: () => (
<VStack position="absolute" inset={0}>
<Banner closable variant="gradient">
<Banner closable layerStyle="defaultGradient">
Banner
</Banner>
</VStack>
Expand All @@ -35,7 +35,7 @@ export const Gradient: Story = {
export const Stacked: Story = {
render: () => (
<VStack gap={0} position="absolute" inset={0}>
<Banner variant="gradient">Banner</Banner>
<Banner layerStyle="defaultGradient">Banner</Banner>
<Banner>Banner</Banner>
</VStack>
),
Expand Down
16 changes: 14 additions & 2 deletions src/components/core/Button/Button.recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const buttonRecipe = defineRecipe({
className: "button",
description: "The styles for the Button component",
base: {
borderWidth: "1px",
cursor: "pointer",
fontWeight: "bold",
borderRadius: "md",
Expand All @@ -27,21 +28,24 @@ export const buttonRecipe = defineRecipe({
variants: {
variant: {
primary: {
borderColor: "accent.default",
color: "accent.fg",
bgColor: "accent.default",
_hover: {
bgColor: "accent.emphasized",
borderColor: "accent.emphasized",
},
_disabled: {
borderColor: "border.disabled",
bgColor: "bg.disabled",
cursor: "not-allowed",
_hover: {
borderColor: "border.disabled",
bgColor: "bg.disabled",
},
},
},
secondary: {
borderWidth: "1px",
borderColor: "border.emphasized",
bgColor: "bg.default",
color: "fg.emphasized",
Expand All @@ -53,40 +57,48 @@ export const buttonRecipe = defineRecipe({
color: "fg.disabled",
cursor: "not-allowed",
_hover: {
background: "transparent",
background: "bg.default",
borderColor: "border.disabled",
color: "fg.disabled",
},
},
},
ghost: {
bgColor: "transparent",
borderColor: "transparent",
color: "fg.emphasized",
_hover: {
color: "fg.default",
background: "accent.subtle",
borderColor: "accent.subtle",
},
_disabled: {
borderColor: "transparent",
color: "fg.disabled",
cursor: "not-allowed",
_hover: {
background: "transparent",
color: "fg.disabled",
borderColor: "transparent",
},
},
},
round: {
borderRadius: "full !important",
color: "accent.fg",
bgColor: "accent.default",
borderColor: "accent.default",
_hover: {
bgColor: "accent.emphasized",
borderColor: "accent.emphasized",
},
_disabled: {
borderColor: "border.disabled",
bgColor: "bg.disabled",
cursor: "not-allowed",
_hover: {
bgColor: "bg.disabled",
borderColor: "border.disabled",
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions src/lib/panda/aniref.preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
fonts,
globalCss,
keyframes,
layerStyles,
recipes,
semanticTokens,
slotRecipes,
Expand All @@ -33,6 +34,7 @@ const anirefPreset = definePreset({
extend: {
breakpoints,
keyframes,
layerStyles,
recipes,
semanticTokens,
slotRecipes,
Expand Down
1 change: 1 addition & 0 deletions src/lib/panda/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const colors = defineTokens.colors({
700: { value: "#45d290" },
800: { value: "#31cd84" },
900: { value: "#28a369" },
950: { value: "#05291d" },
},
tertiary: {
50: { value: "#ffdddf" },
Expand Down
1 change: 1 addition & 0 deletions src/lib/panda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { default as easings } from "./easings";
export { default as fonts } from "./fonts";
export { default as globalCss } from "./globalCss";
export { default as keyframes } from "./keyframes";
export { default as layerStyles } from "./layerStyles";
export { recipes, slotRecipes } from "./recipes";
export { default as semanticTokens } from "./semanticTokens";
export { default as zIndex } from "./zIndex";
24 changes: 24 additions & 0 deletions src/lib/panda/layerStyles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineLayerStyles } from "@pandacss/dev";

const layerStyles = defineLayerStyles({
defaultGradient: {
description: "layer styles for accent gradient",
value: {
background:
// TODO update when colorPalette composition strategy is implemented
"linear-gradient(to right, token(colors.brand.secondary.500), token(colors.accent.default))",
},
},
subtleGradient: {
description: "layer styles for subtle gradient",
value: {
background: {
base: "linear-gradient(to right, token(colors.brand.secondary.50), token(colors.brand.primary.50))",
_dark:
"linear-gradient(to right, token(colors.brand.secondary.950), token(colors.brand.primary.950))",
},
},
},
});

export default layerStyles;

1 comment on commit 5dcc96e

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for ui-storybook ready!

✅ Preview
https://ui-storybook-pkmogn79k-animareflection.vercel.app

Built with commit 5dcc96e.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.