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

Text Component #147

Draft
wants to merge 9 commits into
base: 2.0
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import globalStyles from '../src/lib/global-styles';

// https://storybook.js.org/docs/react/writing-stories/parameters#global-parameters
export const parameters = {
// https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args
actions: { argTypesRegex: '^on.*' },
};

export const decorators = [
(Story) => {
globalStyles();
return <Story />;
},
];
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;
49 changes: 49 additions & 0 deletions src/components/Text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { styled } from '../stitches.config';

const Text = styled('p', {
variants: {
size: {
1: {
fontSize: '$1',
lineHeight: '$1',
},
2: {
fontSize: '$2',
lineHeight: '$2',
},
3: {
fontSize: '$3',
lineHeight: '$2',
},
4: {
fontSize: '$4',
lineHeight: '$3',
},
5: {
fontSize: '$5',
lineHeight: '$3',
},
6: {
fontSize: '$6',
lineHeight: '$4',
},
},
font: {
display: {
fontFamily: '$display',
},
main: {
fontFamily: '$main',
},
mono: {
fontFamily: '$mono',
},
},
},
defaultVariants: {
size: '1',
font: 'main',
},
});

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

This file was deleted.

5 changes: 5 additions & 0 deletions src/lib/font-data.ts

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions src/lib/global-styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { global } from '../stitches.config';
import { GT_AMERICA, GT_AMERICA_MONO, MOJO_ALTIS } from './font-data';

const globalStyles = global({
// fonts
'@font-face': [
{
fontFamily: 'altis-mojoregular',
fontDisplay: 'block',
fontWeight: 'normal',
fontStyle: 'normal',
src: `url(${MOJO_ALTIS}) format("woff")`,
},
{
fontFamily: 'GT America Light',
fontDisplay: 'block',
src: `url(${GT_AMERICA}) format("woff")`,
},
{
fontFamily: 'GT America Mono',
fontDisplay: 'block',
fontWeight: 'normal',
fontStyle: 'normal',
src: `url(${GT_AMERICA_MONO}) format("woff")`,
},
],
body: {
fontFamily: '$main',
},
// reset
'html,body,p,ol,ul,li,dl,dt,dd,blockquote,figure,fieldset,legend,textarea,pre,iframe,hr,h1,h2,h3,h4,h5,h6': {
margin: 0,
padding: 0,
},
'h1,h2,h3,h4,h5,h6': {
fontSize: '100%',
fontWeight: 'normal',
},
ul: {
listStyle: 'none',
},
'button,input,select,textarea': {
margin: 0,
},
html: {
boxSizing: 'border-box',
'-webkit-font-smoothing': 'antialiased',
'-moz-osx-font-smoothing': 'grayscale',
},
'*,*:before,*:after': {
boxSizing: 'inherit',
},
'img,embed,iframe,object,video': {
height: 'auto',
maxWidth: '100%',
},
audio: {
maxWidth: '100%',
},
iframe: {
border: 0,
},
table: {
borderCollapse: 'collapse',
borderSpacing: 0,
},
'td,th': {
padding: 0,
textAlign: 'left',
},
});

export default globalStyles;
Loading