Skip to content

Commit

Permalink
Remove Box from Chip
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Jul 11, 2020
1 parent f857598 commit f542153
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 20 deletions.
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.
2 changes: 2 additions & 0 deletions packages/fuselage/src/components/Box/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
@extend %box;

&--full {
@extend %box--animated;
@extend %box--full;

&::before,
&::after {
@extend %box;
@extend %box--animated;
@extend %box--full;
}
}
Expand Down
30 changes: 21 additions & 9 deletions packages/fuselage/src/components/Chip/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import PropTypes from 'prop-types';
import React from 'react';

import { prependClassName } from '../../helpers/prependClassName';
import { Avatar } from '../Avatar';
import { Box } from '../Box';
import { withBoxStyling } from '../Box/withBoxStyling';
import { Icon } from '../Icon';
import Margins from '../Margins';

Expand All @@ -10,29 +12,39 @@ const defaultRenderDismissSymbol = () => <Icon name='cross' size='x16' />;

const Chip = ({
children,
className,
thumbUrl,
onClick,
onMouseDown,
renderThumb = defaultRenderThumb,
renderDismissSymbol = defaultRenderDismissSymbol,
...props
...rest
}) => {
const onDismiss = onClick || onMouseDown;

return <Box
rcx-chip
is='button'
return <button
type='button'
className={prependClassName(className, 'rcx-box rcx-chip')}
disabled={!onDismiss}
onClick={onDismiss}
{...props}
{...rest}
>
<Margins all='x4'>
{thumbUrl && renderThumb && renderThumb({ url: thumbUrl })}
{children && <span className='rcx-chip__text'>{children}</span>}
{children && <span className='rcx-box rcx-chip__text'>{children}</span>}
{onDismiss && renderDismissSymbol && renderDismissSymbol()}
</Margins>
</Box>;
</button>;
};

export default Chip;
if (process.env.NODE_ENV !== 'production') {
Chip.displayName = 'Chip';

Chip.propTypes = {
thumbUrl: PropTypes.string,
renderThumb: PropTypes.func,
renderDismissSymbol: PropTypes.func,
};
}

export default withBoxStyling(Chip);
2 changes: 1 addition & 1 deletion packages/fuselage/src/components/Chip/stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { Box, Chip, Margins } from '../..';

<Preview>
<Story name='With thumb' decorators={[
(storyFn) => <Box display='flex' margins='-x4'>
(storyFn) => <Box display='flex' margin='-x4'>
<Margins all='x4'>
{storyFn()}
</Margins>
Expand Down
18 changes: 12 additions & 6 deletions packages/fuselage/src/components/Chip/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
@use '../../styles/typography.scss';

.rcx-chip {
@include clickable;
@include typography.use-font-scale('p1');

@extend %box--animated;
@extend %box--full;
@extend %button--secondary;

display: flex;
overflow: hidden;
align-items: center;

min-height: lengths.size(28);

border-width: 0;
overflow: hidden;

@include clickable;
@include typography.use-font-scale('p1');

&.disabled,
&:disabled {
Expand All @@ -22,11 +26,13 @@
}

&__text {
white-space: nowrap;
letter-spacing: inherit;

color: inherit;

font: inherit;
letter-spacing: inherit;

@include typography.use-text-ellipsis;
white-space: nowrap;
}
}
10 changes: 6 additions & 4 deletions packages/fuselage/src/styles/primitives/box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
-moz-osx-font-smoothing: grayscale;
}

%box--full {
margin: lengths.margin('none');
padding: lengths.padding('none');

%box--animated {
transition: all 230ms;

@media (prefers-reduced-motion) {
transition: none;
}
}

%box--full {
margin: lengths.margin('none');
padding: lengths.padding('none');

border-width: lengths.border-width('none');
border-style: solid;
Expand Down

0 comments on commit f542153

Please sign in to comment.