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 9, 2020
1 parent 78d5728 commit 6808855
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 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.
28 changes: 20 additions & 8 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-chip')}
disabled={!onDismiss}
onClick={onDismiss}
{...props}
{...rest}
>
<Margins all='x4'>
{thumbUrl && renderThumb && renderThumb({ url: thumbUrl })}
{children && <span className='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
14 changes: 9 additions & 5 deletions packages/fuselage/src/components/Chip/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
@use '../../styles/typography.scss';

.rcx-chip {
@extend %box;
@extend %button--secondary;

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

@extend %button--secondary;

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

min-height: lengths.size(28);

border-width: 0;
overflow: hidden;

&.disabled,
&:disabled {
Expand All @@ -23,12 +26,13 @@

&__text {
@extend %normal;
white-space: nowrap;
letter-spacing: inherit;

color: inherit;

font: inherit;
letter-spacing: inherit;

@include typography.use-text-ellipsis;
white-space: nowrap;
}
}

0 comments on commit 6808855

Please sign in to comment.