Skip to content

Commit

Permalink
Add ThemeProvider (#200)
Browse files Browse the repository at this point in the history
Fixes #195
  • Loading branch information
krzysztofzuraw authored Jan 12, 2023
1 parent 54a5b7c commit 0a1f2d3
Show file tree
Hide file tree
Showing 19 changed files with 331 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module.exports = {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {},
},
},
extends: [
"eslint:recommended",
Expand Down
14 changes: 13 additions & 1 deletion .storybook/preview.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import React from "react";

import { ThemeProvider } from "../src/theme";

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
Expand All @@ -6,4 +10,12 @@ export const parameters = {
date: /Date$/,
},
},
}
};

export const decorators = [
(Story) => {
return React.createElement(ThemeProvider, {
children: React.createElement(Story),
});
},
];
22 changes: 22 additions & 0 deletions legacy/.storybook/main.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { mergeConfig } = require("vite");

module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
framework: "@storybook/react",
core: {
builder: "@storybook/builder-vite",
},
features: {
storyStoreV7: true,
},
async viteFinal(config) {
return mergeConfig(config, {
plugins: [require("@vanilla-extract/vite-plugin").vanillaExtractPlugin()],
});
},
};
3 changes: 3 additions & 0 deletions legacy/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
window.global = window;
</script>
9 changes: 9 additions & 0 deletions legacy/.storybook/preview.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "8.0.0-pre",
"version": "1.0.0",
"license": "CC-BY-4.0",
"homepage": "https://macaw-ui.vercel.app/",
"repository": {
Expand Down Expand Up @@ -39,10 +39,10 @@
},
"scripts": {
"build:legacy": "cd legacy && npm run build",
"build:next": "npm-run-all check-types-next && vite build",
"build:next": "npm-run-all check-types:next && vite build",
"build-storybook": "cross-env NODE_OPTIONS=--openssl-legacy-provider build-storybook",
"lint:legacy": "cd legacy && npm run lint",
"lint:next": "eslint 'src/**/*.@(tsx|ts|jsx|js)' --fix --config .eslintrc.cjs",
"lint:next": "eslint 'src/**/*.@(tsx|ts|jsx|js)' --fix",
"check-types:next": "tsc",
"check-types:legacy": "cd legacy && npm run build-tsc",
"test:legacy": "cd legacy && npm run test",
Expand All @@ -51,8 +51,7 @@
"test": "npm-run-all test:*",
"build": "npm-run-all build:*",
"dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider start-storybook -p 6006",
"make-release": "release-it pre",
"release": "npm-run-all build make-release",
"release": "npm-run-all build release-it",
"prepare": "is-ci || husky install"
},
"name": "@saleor/macaw-ui",
Expand Down Expand Up @@ -95,13 +94,13 @@
"typescript": "^4.9.3",
"vite": "^3.2.5",
"vite-plugin-dts": "^1.7.1",
"webpack": "^5.75.0"
},
"dependencies": {
"webpack": "^5.75.0",
"@vanilla-extract/css": "^1.9.2",
"@vanilla-extract/recipes": "^0.3.0",
"@vanilla-extract/sprinkles": "^1.5.1"
"@vanilla-extract/sprinkles": "^1.5.1",
"@dessert-box/react": "^0.4.0"
},
"dependencies": {},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
Expand Down
52 changes: 45 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/components/Box/Box.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";

import { Box } from "./Box";

export default {
component: Box,
} as ComponentMeta<typeof Box>;

const Template: ComponentStory<typeof Box> = (args) => (
<Box {...args}>Box component</Box>
);

export const Default = Template.bind({});
Default.args = {
padding: 3,
borderWidth: 1,
borderStyle: "solid",
};
5 changes: 5 additions & 0 deletions src/components/Box/Box.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createBox } from "@dessert-box/react";

import { sprinkles } from "~/theme";

export const Box = createBox({ atoms: sprinkles });
1 change: 1 addition & 0 deletions src/components/Box/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Box";
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Box";
3 changes: 2 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export {};
export * from "./components";
export * from "./theme";
Loading

0 comments on commit 0a1f2d3

Please sign in to comment.