Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

(Feature) Display colors with name and code #55

Merged
merged 4 commits into from
Sep 15, 2020
Merged
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"rimraf": "^3.0.2",
"styled-components": "5.1.1",
"typescript": "3.9.7",
"webpack": "4.44.0",
"webpack": "4.43.0",
"webpack-cli": "^3.3.10",
"webpack-node-externals": "^1.7.2"
},
Expand Down
65 changes: 65 additions & 0 deletions src/colors.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from 'react';
import styled from 'styled-components';
import { parseToHsl } from 'polished';

import { Text, theme } from './index';

const Grid = styled.div`
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
`;

const ColorWrapper = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
margin: 16px;
`;

const ColorDisplay = styled.div<{ color: string }>`
margin: 8px auto;
width: 100px;
height: 100px;
border: 1px solid #000000;
background-color: ${({ color }) => color};
`;

export default {
title: 'Colors',
};

export const ColorsSample = (): React.ReactElement => {
const colors = Object.keys(theme.colors)
.reduce((acc: { name: string; code: string }[], name: string) => {
if (typeof (theme.colors as Record<string, unknown>)[name] === 'string') {
acc.push({
name,
code: ((theme.colors as Record<string, unknown>)[
name
] as string).toUpperCase(),
});
}
return acc;
}, [])
.sort(
({ code: colorA }, { code: colorB }) =>
parseToHsl(colorA).lightness - parseToHsl(colorB).lightness
);

return (
<Grid>
{colors?.map(({ name, code }) => (
<ColorWrapper key={name}>
<ColorDisplay color={code} />
<Text size="md" center>
{name}
</Text>
<Text size="md" center>
{code}
</Text>
</ColorWrapper>
))}
</Grid>
);
};
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export * from './navigation';
export * from './ethereum';
//export * from './surfaces';
export * from './utils';
export * from './';
export { default as theme } from './theme';
66 changes: 1 addition & 65 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3750,21 +3750,6 @@ chokidar@^3.4.0:
optionalDependencies:
fsevents "~2.1.2"

chokidar@^3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.4.1.tgz#e905bdecf10eaa0a0b1db0c664481cc4cbc22ba1"
integrity sha512-TQTJyr2stihpC4Sya9hs2Xh+O2wf+igjL36Y75xx2WdHuiICcn/XJza46Jwt0eT5hVpQOzo3FpY3cj3RVYLX0g==
dependencies:
anymatch "~3.1.1"
braces "~3.0.2"
glob-parent "~5.1.0"
is-binary-path "~2.1.0"
is-glob "~4.0.1"
normalize-path "~3.0.0"
readdirp "~3.4.0"
optionalDependencies:
fsevents "~2.1.2"

chownr@^1.1.1, chownr@^1.1.2:
version "1.1.4"
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b"
Expand Down Expand Up @@ -4769,15 +4754,6 @@ enhanced-resolve@^4.0.0, enhanced-resolve@^4.1.0, enhanced-resolve@^4.1.1:
memory-fs "^0.5.0"
tapable "^1.0.0"

enhanced-resolve@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.3.0.tgz#3b806f3bfafc1ec7de69551ef93cca46c1704126"
integrity sha512-3e87LvavsdxyoCfGusJnrZ5G8SLPOFeHSNpZI/ATL9a5leXo2k0w6MKnbqhdBad9qTobSfB20Ld7UmgoNbAZkQ==
dependencies:
graceful-fs "^4.1.2"
memory-fs "^0.5.0"
tapable "^1.0.0"

enquirer@^2.3.5:
version "2.3.5"
resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.5.tgz#3ab2b838df0a9d8ab9e7dff235b0e8712ef92381"
Expand Down Expand Up @@ -10976,17 +10952,6 @@ watchpack@^1.6.1:
chokidar "^3.4.0"
watchpack-chokidar2 "^2.0.0"

watchpack@^1.7.4:
version "1.7.4"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.7.4.tgz#6e9da53b3c80bb2d6508188f5b200410866cd30b"
integrity sha512-aWAgTW4MoSJzZPAicljkO1hsi1oKj/RRq/OJQh2PKI2UKL04c2Bs+MBOB+BBABHTXJpf9mCwHN7ANCvYsvY2sg==
dependencies:
graceful-fs "^4.1.2"
neo-async "^2.5.0"
optionalDependencies:
chokidar "^3.4.1"
watchpack-chokidar2 "^2.0.0"

web-namespaces@^1.0.0, web-namespaces@^1.1.2:
version "1.1.4"
resolved "https://registry.yarnpkg.com/web-namespaces/-/web-namespaces-1.1.4.tgz#bc98a3de60dadd7faefc403d1076d529f5e030ec"
Expand Down Expand Up @@ -11068,36 +11033,7 @@ webpack-virtual-modules@^0.2.0:
dependencies:
debug "^3.0.0"

webpack@4.44.0:
version "4.44.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.44.0.tgz#3b08f88a89470175f036f4a9496b8a0428668802"
integrity sha512-wAuJxK123sqAw31SpkPiPW3iKHgFUiKvO7E7UZjtdExcsRe3fgav4mvoMM7vvpjLHVoJ6a0Mtp2fzkoA13e0Zw==
dependencies:
"@webassemblyjs/ast" "1.9.0"
"@webassemblyjs/helper-module-context" "1.9.0"
"@webassemblyjs/wasm-edit" "1.9.0"
"@webassemblyjs/wasm-parser" "1.9.0"
acorn "^6.4.1"
ajv "^6.10.2"
ajv-keywords "^3.4.1"
chrome-trace-event "^1.0.2"
enhanced-resolve "^4.3.0"
eslint-scope "^4.0.3"
json-parse-better-errors "^1.0.2"
loader-runner "^2.4.0"
loader-utils "^1.2.3"
memory-fs "^0.4.1"
micromatch "^3.1.10"
mkdirp "^0.5.3"
neo-async "^2.6.1"
node-libs-browser "^2.2.1"
schema-utils "^1.0.0"
tapable "^1.1.3"
terser-webpack-plugin "^1.4.3"
watchpack "^1.7.4"
webpack-sources "^1.4.1"

webpack@^4.33.0, webpack@^4.38.0:
webpack@4.43.0, webpack@^4.33.0, webpack@^4.38.0:
version "4.43.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.43.0.tgz#c48547b11d563224c561dad1172c8aa0b8a678e6"
integrity sha512-GW1LjnPipFW2Y78OOab8NJlCflB7EFskMih2AHdvjbpKMeDJqEgSx24cXXXiPS65+WSwVyxtDsJH6jGX2czy+g==
Expand Down