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

feat(Layout): add container sizing tokens #8671

Merged
merged 18 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
14 changes: 14 additions & 0 deletions packages/layout/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@ export const container = [
container04,
container05,
];
export const sizeXSmall = rem(24);
export const sizeSmall = rem(32);
export const sizeMedium = rem(40);
export const sizeLarge = rem(48);
export const sizeXLarge = rem(64);
export const size2XLarge = rem(80);
export const sizes = {
XSmall: sizeXSmall,
Small: sizeSmall,
Medium: sizeMedium,
Large: sizeLarge,
XLarge: sizeXLarge,
'2XLarge': size2XLarge,
};

// Icon
export const iconSize01 = '1rem';
Expand Down
6 changes: 6 additions & 0 deletions packages/layout/src/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export const unstable_tokens = [
'container03',
'container04',
'container05',
'sizeXSmall',
'sizeSmall',
'sizeMedium',
'sizeLarge',
'sizeXLarge',
'size2XLarge',

// Icon sizes
'iconSize01',
Expand Down
37 changes: 37 additions & 0 deletions packages/layout/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const {
spacing,
layout,
fluidSpacing,
sizes,
} = require('../lib');

async function build() {
Expand Down Expand Up @@ -54,6 +55,42 @@ async function build() {
return buildTokenFile(container, 'container');
},
},
{
filepath: path.join(SCSS_DIR, '_size.scss'),
builder() {
const FILE_BANNER = t.Comment(` Code generated by @carbon/layout. DO NOT EDIT.

Copyright IBM Corp. 2018, 2019

This source code is licensed under the Apache-2.0 license found in the
LICENSE file in the root directory of this source tree.
`);
const convert = {
xSmall: 'xs',
small: 'sm',
medium: 'md',
large: 'lg',
xLarge: 'xl',
'2XLarge': '2xl',
dakahn marked this conversation as resolved.
Show resolved Hide resolved
};

const comment = t.Comment(`/ @type Number
/ @access public
/ @group @carbon/layout`);

return t.StyleSheet([
FILE_BANNER,
t.Newline(),
comment,
...Object.entries(sizes).map(([name, value]) => {
return t.Assignment({
id: t.Identifier(`size-${convert[name]}`),
init: t.SassValue(value),
});
}),
]);
},
},
{
filepath: path.join(SCSS_DIR, '_icon-size.scss'),
builder() {
Expand Down
6 changes: 6 additions & 0 deletions packages/themes/src/white.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ export {
container03,
container04,
container05,
sizeXSmall,
tw15egan marked this conversation as resolved.
Show resolved Hide resolved
sizeSmall,
sizeMedium,
sizeLarge,
sizeXLarge,
size2XLarge,
// Icon sizes
iconSize01,
iconSize02,
Expand Down