Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.

Commit 6ce08c7

Browse files
author
Anthony Brice
authored
Merge pull request #313 from cjdev/vs-chip
Add Chip component
2 parents 51e377b + 60852f6 commit 6ce08c7

7 files changed

Lines changed: 110 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Upcoming
2+
3+
## New Component
4+
5+
- Add Chip component
6+
17
# 6.10.0
28

39
## New Component
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
import { Panel, Body } from '@cjdev/visual-stack/lib/components/Panel';
3+
import { Demo, Snippet } from '../../../components/Demo';
4+
/* s2:start */
5+
import { Chip } from '@cjdev/visual-stack';
6+
/* s2:end */
7+
import Box from '@cjdev/visual-stack/lib/experimental/Box';
8+
9+
export default () => (
10+
<Demo srcFile="/samples/src/containers/Components/Docs/chip.js">
11+
{snippets => {
12+
return (
13+
<div>
14+
<Panel>
15+
<Body>
16+
{/* s1:start */}
17+
<Box direction="row" gap="default">
18+
<Chip backgroundColor="#9C52F7">CJ Performer</Chip>
19+
<Chip backgroundColor="#EA4B93">CJ Spotlight</Chip>
20+
<Chip backgroundColor="#4574E2">Content Certified</Chip>
21+
<Chip backgroundColor="#0CAAAC">New to Network</Chip>
22+
<Chip backgroundColor="#072477">SubAffiliate</Chip>
23+
</Box>
24+
{/* s1:end */}
25+
<Snippet tag="s2" src={snippets} />
26+
<Snippet tag="s1" src={snippets} />
27+
</Body>
28+
</Panel>
29+
</div>
30+
);
31+
}}
32+
</Demo>
33+
);

packages/visual-stack-docs/src/containers/Components/Docs/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import SpinnerDocs from './spinner';
2222
import TableDocs from './table';
2323
import TabLayoutDocs from './tablayout';
2424
import CardDocs from './card';
25+
import ChipDocs from './chip';
2526
import ListViewDocs from './listview';
2627
import ExpandingInputButtonDocs from './expanding-input-button';
2728
import LoadingAnimationDocs from './loading-animation';
@@ -51,7 +52,7 @@ addComponentRoute('list', 'List', <ListDocs />);
5152
addComponentRoute('modal', 'Modal', <ModalDocs />);
5253
addComponentRoute('panel', 'Panel', <PanelDocs />);
5354
addComponentRoute('pageheader', 'Page Header', <PageHeaderDocs />);
54-
addComponentRoute('percentslider', 'Percent Slider', <PercentSliderDocs />)
55+
addComponentRoute('percentslider', 'Percent Slider', <PercentSliderDocs />);
5556
addComponentRoute('select', 'Select', <SelectDocs />);
5657
addComponentRoute('sidenav', 'SideNav', <SideNavDocs />);
5758
addComponentRoute('slidingpanel', 'Sliding Panel', <SlidingPanelDocs />);
@@ -65,6 +66,7 @@ addComponentRoute('spinner', 'Spinner', <SpinnerDocs />);
6566
addComponentRoute('table', 'Table', <TableDocs />);
6667
addComponentRoute('tablayout', 'TabLayout', <TabLayoutDocs />);
6768
addComponentRoute('card', 'Card', <CardDocs />);
69+
addComponentRoute('chip', 'Chip', <ChipDocs />);
6870
addComponentRoute('listview', 'List View', <ListViewDocs />);
6971
addComponentRoute('pagination', 'Pagination', <PaginationDocs />);
7072
addComponentRoute(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.vs-chip {
2+
font-weight: 600;
3+
font-size: 1rem;
4+
line-height: 1rem;
5+
border-radius: 2px;
6+
display: inline-block;
7+
color: #ffffff;
8+
padding: 2px 4px;
9+
text-align: center;
10+
text-transform: uppercase;
11+
width: fit-content;
12+
height: fit-content;
13+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import classNames from 'classnames';
2+
import PropTypes from 'prop-types';
3+
import React from 'react';
4+
import './Chip.css';
5+
import Box from '../../experimental/Box';
6+
7+
export const Chip = ({
8+
children,
9+
className,
10+
backgroundColor,
11+
color,
12+
...restProps
13+
}) => {
14+
return (
15+
<Box
16+
{...restProps}
17+
className={classNames('vs-chip', className)}
18+
style={{
19+
backgroundColor,
20+
color,
21+
}}
22+
>
23+
{children}
24+
</Box>
25+
);
26+
};
27+
28+
Chip.propTypes = {
29+
backgroundColor: PropTypes.string,
30+
children: PropTypes.node,
31+
className: PropTypes.string,
32+
color: PropTypes.string,
33+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { mount } from 'enzyme';
3+
import { Chip } from '../';
4+
5+
import Enzyme from 'enzyme';
6+
import Adapter from 'enzyme-adapter-react-16';
7+
Enzyme.configure({ adapter: new Adapter() });
8+
9+
describe('Chip', () => {
10+
const el = document.createElement('div');
11+
document.body.appendChild(el);
12+
13+
test('should render children', () => {
14+
const wrapper = mount(
15+
<Chip backgroundColor="red" color="blue">
16+
CONTENT CERTIFIED
17+
</Chip>
18+
);
19+
expect(wrapper.find(Chip).text()).toEqual('CONTENT CERTIFIED');
20+
});
21+
});

packages/visual-stack/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import './global';
33
// modules that do not need qualification. i.e., the components
44
// they export can be scoped to VisualStack.<component>
55
export * from './components/Button';
6+
export * from './components/Chip';
67
export * from './components/Spinner';
78

89
// modules that need scoping. i.e. the components they

0 commit comments

Comments
 (0)