This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(foundation): added the first elements to foundation docs
- Loading branch information
1 parent
fcdd454
commit bab9a36
Showing
21 changed files
with
742 additions
and
159 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
package.json | ||
*.hbs | ||
*.css.d.ts | ||
*.css.d.ts | ||
width.scss |
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 |
---|---|---|
|
@@ -5,9 +5,9 @@ | |
"version": "0.0.0-dev", | ||
"author": "Julian Koehn <[email protected]>", | ||
"dependencies": { | ||
"@ruids/components": "^1.4.0", | ||
"@ruids/css": "^1.3.0", | ||
"@ruids/tokens": "^1.3.2", | ||
"@ruids/components": "^1.7.0", | ||
"@ruids/css": "^1.3.2", | ||
"@ruids/tokens": "^1.6.0", | ||
"gatsby": "^2.23.12", | ||
"gatsby-image": "^2.4.9", | ||
"gatsby-plugin-emotion": "^4.3.10", | ||
|
73 changes: 73 additions & 0 deletions
73
packages/website/src/components/ColorSwatch/ColorSwatch.tsx
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,73 @@ | ||
import React, { useMemo } from 'react' | ||
import { styles } from './styles' | ||
import { rgb2cmyk } from '../../helpers/rgb2cmyk' | ||
|
||
type Props = { | ||
name: string | ||
hex: string | ||
} | ||
|
||
const hexToRgb = (hex: string) => { | ||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex) | ||
return result | ||
? { | ||
r: parseInt(result[1], 16), | ||
g: parseInt(result[2], 16), | ||
b: parseInt(result[3], 16), | ||
} | ||
: null | ||
} | ||
|
||
export const ColorSwatch: React.FC<Props> = ({ hex, name }) => { | ||
const { rgb, cmyk } = useMemo(() => { | ||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex) | ||
const r = parseInt(result[1], 16) | ||
const g = parseInt(result[2], 16) | ||
const b = parseInt(result[3], 16) | ||
const rgb = `${r}, ${g}, ${b}` | ||
|
||
const cmyk = rgb2cmyk(r, g, b) | ||
const cmykString = `${cmyk.c}, ${cmyk.m}, ${cmyk.y}, ${cmyk.k}` | ||
return { | ||
rgb, | ||
cmyk: cmykString, | ||
} | ||
}, [hex]) | ||
|
||
return ( | ||
<div className="w-full" css={styles.colorSwatch}> | ||
<div | ||
css={styles.header} | ||
style={{ | ||
backgroundColor: hex, | ||
}} | ||
></div> | ||
<div css={styles.body}> | ||
<div css={styles.wrap}> | ||
<div css={styles.item}> | ||
<div css={styles.label}>Text Class</div> | ||
<div css={styles.value}>text-{name}</div> | ||
</div> | ||
<div css={styles.item}> | ||
<div css={styles.label}>RGB</div> | ||
<div css={styles.value}>{rgb}</div> | ||
</div> | ||
<div css={styles.item}> | ||
<div css={styles.label}>CMYK</div> | ||
<div css={styles.value}>{cmyk}</div> | ||
</div> | ||
</div> | ||
<div css={styles.wrap}> | ||
<div css={styles.item}> | ||
<div css={styles.label}>Bg Class</div> | ||
<div css={styles.value}>bg-{name}</div> | ||
</div> | ||
<div css={styles.item}> | ||
<div css={styles.label}>Hex</div> | ||
<div css={styles.value}>{hex}</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
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,20 @@ | ||
import React from 'react' | ||
import { css } from '@emotion/core' | ||
|
||
export const Swatch: React.FC<{ | ||
hex: string | ||
}> = ({ hex }) => ( | ||
<div | ||
css={css({ | ||
float: 'left', | ||
height: 40, | ||
width: 40, | ||
marginRight: 20, | ||
borderRadius: 4, | ||
border: '1px solid transparent', | ||
})} | ||
style={{ | ||
backgroundColor: hex, | ||
}} | ||
/> | ||
) |
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,2 @@ | ||
export { ColorSwatch } from './ColorSwatch' | ||
export { Swatch } from './Swatch' |
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,49 @@ | ||
import { css } from '@emotion/core' | ||
import tokens from '@ruids/tokens' | ||
|
||
export const styles = { | ||
colorSwatch: css` | ||
box-sizing: border-box; | ||
margin: ${tokens.spacing4}; | ||
border-radius: 6px; | ||
background-color: #f4f5f7; | ||
:after { | ||
content: ' '; | ||
display: table; | ||
clear: both; | ||
} | ||
`, | ||
header: css` | ||
position: relative; | ||
height: 0; | ||
padding-bottom: 50%; | ||
border-radius: 6px 6px 0 0; | ||
border: 1px solid transparent; | ||
`, | ||
body: css` | ||
position: relative; | ||
left: 50%; | ||
float: left; | ||
padding: 10px 0; | ||
transform: translateX(-50%); | ||
`, | ||
wrap: css` | ||
float: left; | ||
padding: 0 15px; | ||
min-width: 65px; | ||
`, | ||
item: css` | ||
padding: 15px 0; | ||
`, | ||
label: css` | ||
font-family: ${tokens.fontSans}; | ||
font-size: 11px; | ||
color: #62748c; | ||
text-transform: uppercase; | ||
line-height: 16px; | ||
`, | ||
value: css` | ||
font-family: ${tokens.fontSans}; | ||
font-size: 14px; | ||
`, | ||
} |
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,49 @@ | ||
import React from 'react' | ||
import { Table, Tag } from '@ruids/components' | ||
import { Swatch } from './ColorSwatch/Swatch' | ||
import tokens from '@ruids/tokens' | ||
|
||
type Props = { | ||
name: string | ||
colors: string[] | ||
} | ||
|
||
const getInitialLetter = (name: string) => { | ||
const letter = name.charAt(0) | ||
|
||
return letter.toUpperCase() | ||
} | ||
|
||
const toClassName = (name: string, color: string) => { | ||
return `-${name.toLowerCase()}-${color}` | ||
} | ||
|
||
export const ColorTable: React.FC<Props> = ({ name, colors }) => { | ||
return ( | ||
<Table> | ||
<Table.Body> | ||
{colors.map((c, i) => ( | ||
<Table.Row key={`${name}-${c}-${i}`}> | ||
<Table.Cell> | ||
<Swatch hex={tokens[`color${name}${c}`]} /> | ||
</Table.Cell> | ||
<Table.Cell> | ||
{getInitialLetter(name)} | ||
{c} | ||
</Table.Cell> | ||
<Table.Cell> | ||
<Tag>{tokens[`color${name}${c}`]}</Tag> | ||
</Table.Cell> | ||
|
||
<Table.Cell> | ||
<Tag>text{toClassName(name, c)}</Tag> | ||
</Table.Cell> | ||
<Table.Cell> | ||
<Tag>bg{toClassName(name, c)}</Tag> | ||
</Table.Cell> | ||
</Table.Row> | ||
))} | ||
</Table.Body> | ||
</Table> | ||
) | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/website/src/components/DocFormatter/DocFormatter.tsx
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,25 @@ | ||
import React, { useMemo } from 'react' | ||
import { Heading } from '@ruids/components' | ||
import { styles } from './styles' | ||
|
||
export const DocFormatter: React.FC<{ | ||
frontmatter: any | ||
}> = ({ frontmatter, children }) => { | ||
const data = useMemo(() => { | ||
return { | ||
title: frontmatter && frontmatter.title, | ||
githubUrl: frontmatter && frontmatter.storybook, | ||
storybookUrl: frontmatter && frontmatter.github, | ||
status: frontmatter && frontmatter.status, | ||
} | ||
}, []) | ||
|
||
return ( | ||
<React.Fragment> | ||
<header css={styles.header}> | ||
{data.title && <Heading is="h3">{data.title}</Heading>} | ||
</header> | ||
<main>{children}</main> | ||
</React.Fragment> | ||
) | ||
} |
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 @@ | ||
export { DocFormatter } from './DocFormatter' |
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,12 @@ | ||
import { css } from '@emotion/core' | ||
import tokens from '@ruids/tokens' | ||
|
||
export const styles = { | ||
header: css` | ||
min-width: 100%; | ||
margin: 0 auto; | ||
padding-bottom: ${tokens.spacing8}; | ||
margin-bottom: ${tokens.spacing8}; | ||
border-bottom: 1px solid ${tokens.colorNeutral30}; | ||
`, | ||
} |
Oops, something went wrong.