Skip to content

Commit 63a8cb3

Browse files
fix(color-token-table): started implementing carbon themes
1 parent 08e7be9 commit 63a8cb3

File tree

12 files changed

+216
-54
lines changed

12 files changed

+216
-54
lines changed
1.2 MB
Binary file not shown.
-1.2 MB
Binary file not shown.
250 KB
Binary file not shown.
-256 KB
Binary file not shown.
2.08 MB
Binary file not shown.
-2.08 MB
Binary file not shown.

docs/CONTENT.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ This will render the following set of examples:
279279

280280
- `<component-overview>`
281281

282+
**Color Token Table** (content pulled from data/guidelines/color-tokens.js)
283+
284+
- `<color-token-table>
285+
282286
## Component Page Components:
283287

284288
```

packages/addons-website/src/components/WebsiteFooter/WebsiteFooter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { prefix } = settings;
77

88
const IBMLogo = (
99
<svg width="81" height="32" xmlns="http://www.w3.org/2000/svg">
10-
<g fill="#BEBDBD" fill-rule="evenodd">
10+
<g fill="#BEBDBD" fillRule="evenodd">
1111
<path d="M0 32h15.689v-2.038H0zM0 27.721h15.689v-2.038H0zM4.483 23.442h6.724v-2.037H4.483zM4.483 19.164h6.724v-2.038H4.483zM4.483 14.885h6.724v-2.037H4.483zM4.482 10.606h6.724V8.568H4.482zM0 6.327h15.689V4.29H0zM0 2.049h15.689V.011H0zM17.93 29.963V32h16.504a8.521 8.521 0 0 0 5.54-2.037H17.93zM17.93 25.683v2.038h23.914a8.535 8.535 0 0 0 .85-2.038H17.93zM22.412 23.442h6.724v-2.037h-6.724zM40.124 17.126H22.412v2.038H41.77a8.62 8.62 0 0 0-1.645-2.038M22.413 12.848v2.036h17.786a8.612 8.612 0 0 0 1.644-2.037h-19.43zM42.693 6.327a8.447 8.447 0 0 0-.85-2.037H17.93v2.037h24.763zM39.974 2.049a8.521 8.521 0 0 0-5.54-2.037H17.93v2.037h22.044zM22.412 10.606h6.724V8.568h-6.724zM35.453 10.606h7.29a8.603 8.603 0 0 0 .248-2.038h-7.538v2.038zM35.453 21.405v2.037h7.538c0-.703-.09-1.384-.248-2.037h-7.29zM57.457 0H44.825v2.038h13.34zM44.826 32h11.21v-2.038h-11.21zM44.826 27.72h11.21v-2.038h-11.21zM49.309 23.439h6.727v-2.038h-6.727zM49.309 19.159h6.727v-2.038h-6.727zM69.488 32h11.21v-2.038h-11.21zM69.488 27.72h11.21v-2.038h-11.21zM69.488 23.439h6.726v-2.038h-6.726zM69.487 19.159h6.726v-2.038h-6.726zM69.488 14.879h6.726V12.84H63.606l-.707 2.038h5.903l.686-1.94zM61.916 12.84H49.31v2.039h6.726v-1.94l.686 1.94h5.903zM76.213 8.56H65.091l-.707 2.038h11.83zM68.06 0l-.706 2.038h13.344V0zM62.757 32l.72-2.038h-1.432zM61.254 27.72h3.015l.72-2.038h-4.455zM59.743 23.44h6.037l.72-2.039h-7.476zM58.232 19.159h9.06l.719-2.038h-10.5zM49.309 10.598h11.83l-.707-2.038H49.309zM65.868 6.318h14.83V4.28H66.576zM58.947 4.28H44.826v2.038h14.828z" />
1212
</g>
1313
</svg>

src/components/ColorTokenTable/ColorTokenTable.js

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { CopyToClipboard } from 'react-copy-to-clipboard/lib/Component';
1212

1313
import colorTokens from '../../data/guidelines/color-tokens';
1414

15+
import { themes } from '@carbon/themes';
16+
1517
export default class ColorTokenTable extends React.Component {
1618
static propTypes = {};
1719

@@ -27,21 +29,34 @@ export default class ColorTokenTable extends React.Component {
2729

2830
renderValue = (token, tokenInfo) => {
2931
const currentTheme = this.state.theme;
30-
const value = tokenInfo.value;
32+
console.log(themes);
33+
let newFormattedToken = token.replace('$', '');
34+
newFormattedToken = newFormattedToken.split('-');
35+
newFormattedToken = `${newFormattedToken[0]}${newFormattedToken[1]
36+
.charAt(1)
37+
.toUpperCase() + newFormattedToken[1].substring(1)}`;
38+
console.log(newFormattedToken);
39+
const formattedToken = token.replace('$', '').replace('-', '');
40+
// const value = tokenInfo.value;
3141
return (
3242
<div className="color-token-value">
3343
<ul>
34-
<li>{value[currentTheme].name}</li>
44+
{/* <li>{value[currentTheme].name}</li> */}
3545
<li></li>
36-
<li>{value[currentTheme].hex}</li>
46+
<li>{themes[currentTheme][formattedToken]}</li>
3747
</ul>
3848
<div>
3949
<div
4050
className="color-token-value__block"
41-
style={{ backgroundColor: value[currentTheme].hex }}
51+
style={{
52+
backgroundColor: themes[currentTheme][formattedToken],
53+
border:
54+
themes[currentTheme][formattedToken] === '#ffffff' &&
55+
'1px solid #BEBEBE',
56+
}}
4257
/>
4358
<OverflowMenu floatingMenu={false}>
44-
<CopyToClipboard text={value[currentTheme].hex}>
59+
<CopyToClipboard text={themes[currentTheme][formattedToken]}>
4560
<OverflowMenuItem itemText="Copy hex" />
4661
</CopyToClipboard>
4762
<CopyToClipboard text={token}>
@@ -53,17 +68,17 @@ export default class ColorTokenTable extends React.Component {
5368
);
5469
};
5570

56-
renderToken = (token, tokenInfo) => {
71+
renderToken = (token, tokenInfo, key) => {
5772
const roles = tokenInfo.role.map((role, i) => {
5873
return (
59-
<li>
74+
<li key={i}>
6075
{role}
6176
{i !== tokenInfo.role.length - 1 && ';'}
6277
</li>
6378
);
6479
});
6580
return (
66-
<tr>
81+
<tr key={key}>
6782
<td>
6883
<code>{token}</code>
6984
</td>
@@ -83,9 +98,9 @@ export default class ColorTokenTable extends React.Component {
8398
className="color-token-table__theme-switcher"
8499
onChange={this.switchTheme}>
85100
<Switch name="white" text="White" />
86-
<Switch name="gray-10" text="Gray 10" />
87-
<Switch name="gray-100" text="Gray 100" />
88-
<Switch name="gray-90" text="Gray 90" />
101+
<Switch name="g10" text="Gray 10" />
102+
<Switch name="g100" text="Gray 100" />
103+
<Switch name="g90" text="Gray 90" />
89104
</ContentSwitcher>
90105
</div>
91106
<div className="ibm--col-lg-7 ibm--offset-lg-4">
@@ -101,8 +116,13 @@ export default class ColorTokenTable extends React.Component {
101116
</tr>
102117
</thead>
103118
<tbody>
104-
{Object.keys(colorTokens).map(token => {
105-
return this.renderToken(token, colorTokens[token]);
119+
{Object.keys(colorTokens['core-tokens']).map((token, i) => {
120+
console.log(colorTokens['core-tokens'][token]);
121+
return this.renderToken(
122+
token,
123+
colorTokens['core-tokens'][token],
124+
i
125+
);
106126
})}
107127
</tbody>
108128
</table>
@@ -120,8 +140,12 @@ export default class ColorTokenTable extends React.Component {
120140
</tr>
121141
</thead>
122142
<tbody>
123-
{Object.keys(colorTokens).map(token => {
124-
return this.renderToken(token, colorTokens[token]);
143+
{Object.keys(colorTokens['core-tokens']).map((token, i) => {
144+
return this.renderToken(
145+
token,
146+
colorTokens['core-tokens'][token],
147+
i
148+
);
125149
})}
126150
</tbody>
127151
</table>
@@ -139,9 +163,15 @@ export default class ColorTokenTable extends React.Component {
139163
</tr>
140164
</thead>
141165
<tbody>
142-
{Object.keys(colorTokens).map(token => {
143-
return this.renderToken(token, colorTokens[token]);
144-
})}
166+
{Object.keys(colorTokens['interaction-tokens']).map(
167+
(token, i) => {
168+
return this.renderToken(
169+
token,
170+
colorTokens['interaction-tokens'][token],
171+
i
172+
);
173+
}
174+
)}
145175
</tbody>
146176
</table>
147177
</div>

src/components/ColorTokenTable/color-token-table.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
color: $text-01;
2121

2222
&:hover {
23-
background-color: $ibm-colors__gray--30; // $hover-ui
23+
background-color: #e5e5e5; // $hover-ui
2424
}
2525
}
2626

0 commit comments

Comments
 (0)