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: New Box props #213

Merged
merged 19 commits into from
Apr 28, 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
106 changes: 52 additions & 54 deletions packages/fuselage-tokens/typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,60 +26,58 @@ const fontMono = [
];

export default {
h1: {
fontFamily: fontSans,
fontSize: 22,
fontWeight: 400,
letterSpacing: 0,
lineHeight: 32,
fontFamilies: {
sans: fontSans,
mono: fontMono,
},
s1: {
fontFamily: fontSans,
fontSize: 16,
fontWeight: 400,
letterSpacing: 0,
lineHeight: 22,
},
s2: {
fontFamily: fontSans,
fontSize: 16,
fontWeight: 500,
letterSpacing: 0,
lineHeight: 22,
},
p1: {
fontFamily: fontSans,
fontSize: 14,
fontWeight: 400,
letterSpacing: 0,
lineHeight: 20,
},
p2: {
fontFamily: fontSans,
fontSize: 14,
fontWeight: 500,
letterSpacing: 0,
lineHeight: 20,
},
c1: {
fontFamily: fontSans,
fontSize: 12,
fontWeight: 400,
letterSpacing: 0,
lineHeight: 16,
},
c2: {
fontFamily: fontSans,
fontSize: 12,
fontWeight: 600,
letterSpacing: 0,
lineHeight: 16,
},
micro: {
fontFamily: fontSans,
fontSize: 10,
fontWeight: 600,
letterSpacing: 0.2,
lineHeight: 12,
fontScales: {
h1: {
fontSize: 22,
fontWeight: 400,
letterSpacing: 0,
lineHeight: 32,
},
s1: {
fontSize: 16,
fontWeight: 400,
letterSpacing: 0,
lineHeight: 22,
},
s2: {
fontSize: 16,
fontWeight: 500,
letterSpacing: 0,
lineHeight: 22,
},
p1: {
fontSize: 14,
fontWeight: 400,
letterSpacing: 0,
lineHeight: 20,
},
p2: {
fontSize: 14,
fontWeight: 500,
letterSpacing: 0,
lineHeight: 20,
},
c1: {
fontSize: 12,
fontWeight: 400,
letterSpacing: 0,
lineHeight: 16,
},
c2: {
fontSize: 12,
fontWeight: 600,
letterSpacing: 0,
lineHeight: 16,
},
micro: {
fontSize: 10,
fontWeight: 600,
letterSpacing: 0.2,
lineHeight: 12,
},
},
}
19 changes: 8 additions & 11 deletions packages/fuselage-tokens/typography.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$font-sans:
$-font-sans:
Inter,
-apple-system,
BlinkMacSystemFont,
Expand All @@ -15,66 +15,63 @@ $font-sans:
Arial,
sans-serif;

$font-mono:
$-font-mono:
Menlo,
Monaco,
Consolas,
'Liberation Mono',
'Courier New',
monospace;

$typography: (
$font-families: (
sans: $-font-sans,
mono: $-font-mono,
);

$font-scales: (
h1: (
font-family: $font-sans,
font-size: 22,
font-weight: 400,
letter-spacing: 0,
line-height: 32,
),
s1: (
font-family: $font-sans,
font-size: 16,
font-weight: 400,
letter-spacing: 0,
line-height: 22,
),
s2: (
font-family: $font-sans,
font-size: 16,
font-weight: 500,
letter-spacing: 0,
line-height: 22,
),
p1: (
font-family: $font-sans,
font-size: 14,
font-weight: 400,
letter-spacing: 0,
line-height: 20,
),
p2: (
font-family: $font-sans,
font-size: 14,
font-weight: 500,
letter-spacing: 0,
line-height: 20,
),
c1: (
font-family: $font-sans,
font-size: 12,
font-weight: 400,
letter-spacing: 0,
line-height: 16,
),
c2: (
font-family: $font-sans,
font-size: 12,
font-weight: 600,
letter-spacing: 0,
line-height: 16,
),
micro: (
font-family: $font-sans,
font-size: 10,
font-weight: 600,
letter-spacing: 0.2,
Expand Down
2 changes: 1 addition & 1 deletion packages/fuselage-ui-kit/src/Section.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Fields = ({ fields, parser }) => (
export const Section = ({ blockId, appId, text, fields, accessory, parser }) => <Block>
<Grid>
<Grid.Item>
{text && <Box is='span' textStyle='p1' textColor='default'>{parser.text(text)}</Box>}
{text && <Box is='span' textStyle='p1' color='default'>{parser.text(text)}</Box>}
{fields && <Fields fields={fields} parser={parser} />}
</Grid.Item>
{ accessory && < Flex.Item grow={0}>
Expand Down
2 changes: 1 addition & 1 deletion packages/fuselage-ui-kit/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class MessageParser extends UiKitParserMessage {
ELEMENT_TYPES.PLAIN_TEXT,
ELEMENT_TYPES.MARKDOWN,
].includes(element.type) ? (
<Box is='span' textStyle='c1' textColor='info'>
<Box is='span' textStyle='c1' color='info'>
{this.renderContext(element, BLOCK_CONTEXT.CONTEXT, this)}
</Box>
)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
10 changes: 5 additions & 5 deletions packages/fuselage/.storybook/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import React from 'react';
import { Box, Text } from '../src';

export function PropsVariationSection({ component: Component, common = {}, xAxis = {}, yAxis = {} }) {
return <Box is='table' style={{ borderCollapse: 'collapse', margin: '1rem auto' }}>
return <Box is='table' marginBlock='x16' marginInline='auto' style={{ borderCollapse: 'collapse' }}>
<Box is='thead'>
<Box is='tr'>
<Box is='th' />
{Object.keys(xAxis).map((xVariation, key) =>
<Box key={key} is='th' textColor='hint' textStyle='c1'>{xVariation}</Box>)}
<Box key={key} is='th' color='hint' fontScale='c1'>{xVariation}</Box>)}
</Box>
</Box>
<Box is='tbody'>
{Object.entries(yAxis).map(([yVariation, yProps], y) => (
<Box key={y} is='tr'>
<Box is='th' textColor='hint' textStyle='c1'>{yVariation}</Box>
{Object.values(xAxis).map((xProps, x) => <Box key={x} is='td' style={{ margin: 0, padding: '0.5rem 1rem' }}>
<Box style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Box is='th' color='hint' fontScale='c1'>{yVariation}</Box>
{Object.values(xAxis).map((xProps, x) => <Box key={x} is='td' margin='none' paddingBlock='x8' paddingInline='x16'>
<Box display='flex' alignItems='center' justifyContent='center'>
<Component {...common} {...xProps} {...yProps} />
</Box>
</Box>)}
Expand Down
4 changes: 3 additions & 1 deletion packages/fuselage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
"dependencies": {
"@rocket.chat/css-in-js": "^0.8.0",
"@rocket.chat/fuselage-tokens": "^0.8.0",
"@rocket.chat/icons": "^0.8.0"
"@rocket.chat/icons": "^0.8.0",
"invariant": "^2.2.4",
"mem": "^6.1.0"
},
"devDependencies": {
"@babel/core": "^7.4.5",
Expand Down
10 changes: 5 additions & 5 deletions packages/fuselage/src/components/Accordion/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ export function Item({

const barProps = noncollapsible ? nonCollapsibleProps : collapsibleProps;

return <Box componentClassName='rcx-accordion-item' is='section' className={className} {...props}>
{title && <Box componentClassName='rcx-accordion-item__bar' mod-disabled={disabled} {...barProps}>
<Box componentClassName='rcx-accordion-item__title' is='h1' id={titleId}>{title}</Box>
return <Box is='section' rcx-accordion-item className={className} {...props}>
{title && <Box rcx-accordion-item__bar rcx-accordion-item__bar--disabled={disabled} {...barProps}>
<Box is='h1' rcx-accordion-item__title id={titleId}>{title}</Box>
{!noncollapsible && <>
{(disabled || onToggleEnabled)
&& <Box componentClassName='rcx-accordion-item__toggle-switch'>
&& <Box rcx-accordion-item__toggle-switch>
<ToggleSwitch checked={!disabled} onClick={handleToggleClick} onChange={onToggleEnabled} />
</Box>}
<Chevron size='x24' up={expanded} />
</>}
</Box>}
<Box componentClassName='rcx-accordion-item__panel' id={panelId} mod-expanded={panelExpanded} role='region'>
<Box rcx-accordion-item__panel rcx-accordion-item__panel--expanded={panelExpanded} id={panelId} role='region'>
{children}
</Box>
</Box>;
Expand Down
12 changes: 6 additions & 6 deletions packages/fuselage/src/components/Accordion/Item.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A collapsible panel.
<Story name='Default'>
<Accordion>
<Accordion.Item title='Item'>
<Box textStyle='p1' textColor='default' marginBlockEnd='x16'>Content</Box>
<Box color='default' fontScale='p1' marginBlockEnd='x16'>Content</Box>
</Accordion.Item>
</Accordion>
</Story>
Expand All @@ -28,7 +28,7 @@ A collapsible panel.
<Story name='Expanded'>
<Accordion>
<Accordion.Item title='Item' defaultExpanded>
<Box textStyle='p1' textColor='default' marginBlockEnd='x16'>Content</Box>
<Box color='default' fontScale='p1' marginBlockEnd='x16'>Content</Box>
</Accordion.Item>
</Accordion>
</Story>
Expand All @@ -40,7 +40,7 @@ A collapsible panel.
<Story name='Noncollapsible'>
<Accordion>
<Accordion.Item title='Item' noncollapsible>
<Box textStyle='p1' textColor='default' marginBlockEnd='x16'>Content</Box>
<Box color='default' fontScale='p1' marginBlockEnd='x16'>Content</Box>
</Accordion.Item>
</Accordion>
</Story>
Expand All @@ -56,7 +56,7 @@ is <LinkTo kind='Containers|Accordion/Accordion.Item' story='Noncollapsible'>non
<Story name='Without Title'>
<Accordion>
<Accordion.Item>
<Box textStyle='p1' textColor='default' marginBlockEnd='x16'>Content</Box>
<Box color='default' fontScale='p1' marginBlockEnd='x16'>Content</Box>
</Accordion.Item>
</Accordion>
</Story>
Expand All @@ -70,7 +70,7 @@ is <LinkTo kind='Containers|Accordion/Accordion.Item' story='Noncollapsible'>non
<Story name='Enabled'>
<Accordion>
<Accordion.Item title='Item' onToggleEnabled={action('toggleEnabled')}>
<Box textStyle='p1' textColor='default' marginBlockEnd='x16'>Content</Box>
<Box color='default' fontScale='p1' marginBlockEnd='x16'>Content</Box>
</Accordion.Item>
</Accordion>
</Story>
Expand All @@ -82,7 +82,7 @@ is <LinkTo kind='Containers|Accordion/Accordion.Item' story='Noncollapsible'>non
<Story name='Disabled'>
<Accordion>
<Accordion.Item title='Item' disabled onToggleEnabled={action('toggleEnabled')}>
<Box textStyle='p1' textColor='default' marginBlockEnd='x16'>Content</Box>
<Box color='default' fontScale='p1' marginBlockEnd='x16'>Content</Box>
</Accordion.Item>
</Accordion>
</Story>
Expand Down
2 changes: 1 addition & 1 deletion packages/fuselage/src/components/Accordion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Item } from './Item';
import { Box } from '../Box';

export function Accordion(props) {
return <Box componentClassName='rcx-accordion' {...props} />;
return <Box rcx-accordion {...props} />;
}

Accordion.propTypes = {
Expand Down
6 changes: 3 additions & 3 deletions packages/fuselage/src/components/Accordion/stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ sections of content.
<Story name='Default'>
<Accordion>
<Accordion.Item title='Item #1' defaultExpanded>
<Box textStyle='p1' textColor='default' marginBlockEnd='x16'>Content #1</Box>
<Box color='default' fontScale='p1' marginBlockEnd='x16'>Content #1</Box>
</Accordion.Item>
<Accordion.Item title='Item #2'>
<Box textStyle='p1' textColor='default' marginBlockEnd='x16'>Content #2</Box>
<Box color='default' fontScale='p1' marginBlockEnd='x16'>Content #2</Box>
</Accordion.Item>
<Accordion.Item title='Item #3'>
<Box textStyle='p1' textColor='default' marginBlockEnd='x16'>Content #3</Box>
<Box color='default' fontScale='p1' marginBlockEnd='x16'>Content #3</Box>
</Accordion.Item>
</Accordion>
</Story>
Expand Down
Loading