Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ThemeProvider: add component & add cambio versions of Button / IconBu…
…tton & LinkButton (#317) * ThemeProvider: add component & base cambio theme * Add theme selector * Button / IconButton / LinkButton: add Cambio variants * Remove xl size * Update colors & sizes * Add tests + fallback colors
- Loading branch information
1 parent
611e0c4
commit 0bbf4b1
Showing
32 changed files
with
2,000 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@cambly/syntax-design-tokens": minor | ||
"@cambly/syntax-core": minor | ||
"@syntax/storybook": minor | ||
--- | ||
|
||
Add ThemeProvider & styles for Button / IconButton & LinkButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
import React from "react"; | ||
import "@cambly/syntax-design-tokens/dist/css/variables.css"; | ||
import { initializeRTL } from "storybook-addon-rtl"; | ||
import { Preview } from "@storybook/react"; | ||
import ThemeProvider from "../../../packages/syntax-core/src/ThemeProvider/ThemeProvider"; | ||
|
||
initializeRTL(); | ||
const preview: Preview = { | ||
globalTypes: { | ||
theme: { | ||
description: "Global theme for components", | ||
defaultValue: "classic", | ||
toolbar: { | ||
title: "Theme", | ||
icon: "circlehollow", | ||
items: ["classic", "cambio"], | ||
dynamicTitle: true, | ||
}, | ||
}, | ||
}, | ||
decorators: [ | ||
(Story, context) => { | ||
const theme = context.globals.theme; | ||
return ( | ||
<ThemeProvider themeName={theme}> | ||
<Story /> | ||
</ThemeProvider> | ||
); | ||
}, | ||
], | ||
}; | ||
|
||
export default preview; | ||
|
||
export const decorators = [(Story) => <Story />]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default function classicSize( | ||
size: "sm" | "md" | "lg" | "xl", | ||
): "sm" | "md" | "lg" { | ||
return size === "xl" ? "lg" : size; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
export function classicColor( | ||
color: | ||
| "primary" | ||
| "secondary" | ||
| "tertiary" | ||
| "destructive-primary" | ||
| "destructive-secondary" | ||
| "destructive-tertiary" | ||
| "branded" | ||
| "success" | ||
| "success-primary" | ||
| "success-secondary" | ||
| "success-tertiary" | ||
| "inverse", | ||
): | ||
| "primary" | ||
| "secondary" | ||
| "tertiary" | ||
| "destructive-primary" | ||
| "destructive-secondary" | ||
| "branded" | ||
| "success" | ||
| "inverse" { | ||
if (color === "destructive-tertiary") { | ||
return "destructive-secondary"; | ||
} else if ( | ||
color === "success-primary" || | ||
color === "success-secondary" || | ||
color === "success-tertiary" | ||
) { | ||
return "success"; | ||
} | ||
return color; | ||
} | ||
|
||
export function cambioColor( | ||
color: | ||
| "primary" | ||
| "secondary" | ||
| "tertiary" | ||
| "destructive-primary" | ||
| "destructive-secondary" | ||
| "destructive-tertiary" | ||
| "branded" | ||
| "success" | ||
| "success-primary" | ||
| "success-secondary" | ||
| "success-tertiary" | ||
| "inverse", | ||
): | ||
| "primary" | ||
| "secondary" | ||
| "tertiary" | ||
| "destructive-primary" | ||
| "destructive-secondary" | ||
| "destructive-tertiary" | ||
| "branded" | ||
| "success-primary" | ||
| "success-secondary" | ||
| "success-tertiary" { | ||
if (color === "success") { | ||
return "success-primary"; | ||
} | ||
// TODO - validate with AJ | ||
else if (color === "inverse") { | ||
return "secondary"; | ||
} | ||
return color; | ||
} |
Oops, something went wrong.