Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box Component / Stitches Setup #142

Open
wants to merge 5 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/carbon
lts/fermium
3 changes: 0 additions & 3 deletions example/.npmignore

This file was deleted.

14 changes: 0 additions & 14 deletions example/index.html

This file was deleted.

14 changes: 0 additions & 14 deletions example/index.tsx

This file was deleted.

24 changes: 0 additions & 24 deletions example/package.json

This file was deleted.

18 changes: 0 additions & 18 deletions example/tsconfig.json

This file was deleted.

44 changes: 34 additions & 10 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,8 @@
"tsdx": "^0.14.1",
"tslib": "^2.2.0",
"typescript": "^4.2.4"
},
"dependencies": {
"@stitches/react": "^0.1.9"
}
}
7 changes: 7 additions & 0 deletions src/components/Box.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { styled } from '../stitches.config';

const Box = styled('div', {
boxSizing: 'border-box',
});

export default Box;
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export { default as Box } from './components/Box';
export {
styled,
css,
theme,
getCssString,
global,
keyframes,
} from './stitches.config';
15 changes: 0 additions & 15 deletions src/index.tsx

This file was deleted.

22 changes: 22 additions & 0 deletions src/stitches.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createCss } from '@stitches/react';

export const {
styled,
css,
global,
keyframes,
getCssString,
theme,
} = createCss({
theme: {
space: {
0: '0px', // 0
1: 'clamp(0.25rem, 0.15rem + 0.49vw, 0.50rem)', // 4-8
2: 'clamp(0.50rem, 0.30rem + 0.98vw, 1.00rem)', // 8-16
3: 'clamp(1.13rem, 0.98rem + 0.73vw, 1.50rem)', // 18-24
4: 'clamp(2.75rem, 1.68rem + 5.37vw, 5.50rem)', // 44-88
5: 'clamp(5.50rem, 3.35rem + 10.73vw, 11.00rem)', // 88-176
6: 'clamp(11.00rem, 6.71rem + 21.46vw, 22.00rem)', // 176-352
},
},
});
29 changes: 15 additions & 14 deletions stories/Thing.stories.tsx → stories/Box.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import React from 'react';
import { Meta, Story } from '@storybook/react';
import { Thing, Props } from '../src';
import Box from '../src/components/Box';

const meta: Meta = {
title: 'Welcome',
component: Thing,
argTypes: {
children: {
control: {
type: 'text',
},
},
},
parameters: {
controls: { expanded: true },
},
title: 'Box',
component: Box,
};

export default meta;

const Template: Story<Props> = args => <Thing {...args} />;
const Template: Story = () => (
<Box>
<Box
css={{
marginBottom: '$6',
}}
>
This is a box
</Box>
<Box>This is another box</Box>
</Box>
);

// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
// https://storybook.js.org/docs/react/workflows/unit-testing
Expand Down
11 changes: 0 additions & 11 deletions test/blah.test.tsx

This file was deleted.