Skip to content

Commit

Permalink
Add divider component
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrtenz committed Jul 3, 2024
1 parent 613aebe commit 5f8cdfa
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/examples/packages/jsx/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "vIy2eWpUsteiyiWqSxoHAThE2qB2ge3E8i/fOJmChLQ=",
"shasum": "vvYDxG244unWDuN9QzSS6SazmKhqwX69oSsCmgjzBZQ=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
10 changes: 1 addition & 9 deletions packages/examples/packages/jsx/src/components/Counter.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import type { SnapComponent } from '@metamask/snaps-sdk/jsx';
import {
Copyable,
Bold,
Button,
Box,
Text,
Tooltip,
} from '@metamask/snaps-sdk/jsx';
import { Bold, Button, Box, Text, Tooltip } from '@metamask/snaps-sdk/jsx';

/**
* The props for the {@link Counter} component.
Expand Down Expand Up @@ -46,7 +39,6 @@ export const Counter: SnapComponent<CounterProps> = ({ count }) => {
</Text>
</Tooltip>
<Button name="increment">Increment</Button>
<Copyable value="test" sensitive={true} />
</Box>
);
};
32 changes: 32 additions & 0 deletions packages/snaps-sdk/src/jsx/components/Divider.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Meta, Story } from '@metamask/snaps-storybook';

import { Box } from './Box';
import { Divider } from './Divider';
import { Text } from './Text';

const meta: Meta<typeof Divider> = {
title: 'Divider',
component: Divider,
};

export default meta;

/**
* The divider component renders a horizontal line between elements.
*/
export const Default: Story = {
render: () => <Divider />,
};

/**
* It can be used to separate sections of content.
*/
export const WithText: Story = {
render: () => (
<Box>
<Text>Some text</Text>
<Divider />
<Text>Some more text</Text>
</Box>
),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineStyle, defineStyleConfig } from '@chakra-ui/react';

export const styles = defineStyleConfig({
baseStyle: defineStyle({
borderColor: 'border.default',
}),
});
12 changes: 12 additions & 0 deletions packages/snaps-storybook/src/components/snaps/divider/Divider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Divider as ChakraDivider } from '@chakra-ui/react';
import type { FunctionComponent } from 'react';

/**
* A divider component, which is used to create a horizontal line between
* elements.
*
* This component does not have any props.
*
* @returns A divider element.
*/
export const Divider: FunctionComponent = () => <ChakraDivider />;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Divider as Component } from './Divider';
export { styles } from './Divider.styles';
2 changes: 2 additions & 0 deletions packages/snaps-storybook/src/components/snaps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as Address from './address';
import * as Box from './box';
import * as Button from './button';
import * as Copyable from './copyable';
import * as Divider from './divider';
import * as Heading from './heading';
import * as Row from './row';
import * as Text from './text';
Expand All @@ -18,6 +19,7 @@ export const SNAPS_COMPONENTS: Record<string, Component> = {
Box,
Button,
Copyable,
Divider,
Heading,
Row,
Text,
Expand Down

0 comments on commit 5f8cdfa

Please sign in to comment.