Skip to content

Commit

Permalink
feat(react): add card component
Browse files Browse the repository at this point in the history
  • Loading branch information
dackmin committed Sep 30, 2022
1 parent d8fe8c3 commit 930122e
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/react/lib/Card/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { forwardRef, useImperativeHandle, useRef } from 'react';
import { classNames } from '@junipero/core';

const Card = forwardRef(({ className, ...rest }, ref) => {
const innerRef = useRef();

useImperativeHandle(ref, () => ({
innerRef,
isJunipero: true,
}));

return (
<div
{ ...rest }
className={classNames('junipero', 'card', className)}
ref={innerRef}
/>
);
});

Card.displayName = 'Card';
Card.propTypes = {};

export default Card;
7 changes: 7 additions & 0 deletions packages/react/lib/Card/index.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Card from './index';

export default { title: 'react/Card' };

export const basic = () => (
<Card>This is a card</Card>
);
11 changes: 11 additions & 0 deletions packages/react/lib/Card/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { render } from '@testing-library/react';

import Card from './index';

describe('<Card />', () => {
it('should render', () => {
const { container, unmount } = render(<Card />);
expect(container).toMatchSnapshot();
unmount();
});
});
9 changes: 9 additions & 0 deletions packages/react/lib/Card/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Card /> should render 1`] = `
<div>
<div
class="junipero card"
/>
</div>
`;
11 changes: 11 additions & 0 deletions packages/theme/lib/Card.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@use "vars" as vars

.junipero.card
--background-color: var(--junipero-seashell)
--shadow-color: rgba(26, 26, 26, 0.1)

display: block
border-radius: 10px
padding: 20px
background: var(--background-color)
box-shadow: #{vars.$cardShadow}

0 comments on commit 930122e

Please sign in to comment.