-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(divider): create new component (#692)
- Loading branch information
1 parent
9fa6c2d
commit 53716d7
Showing
8 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.atom-divider { | ||
background-color: var(--color-neutral-light-3); | ||
height: 1px; | ||
width: 100%; | ||
|
||
&.is-vertical { | ||
height: 100%; | ||
width: 1px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { newSpecPage } from '@stencil/core/testing' | ||
|
||
import { AtomDivider } from './divider' | ||
|
||
describe('atom-divider', () => { | ||
it('should render with default prop horizontal', async () => { | ||
const page = await newSpecPage({ | ||
components: [AtomDivider], | ||
html: `<atom-divider type='horizontal'/>`, | ||
}) | ||
|
||
await page.waitForChanges() | ||
|
||
expect(page.root).toEqualHtml(` | ||
<atom-divider type='horizontal'> | ||
<mock:shadow-root> | ||
<div aria-hidden="" class="atom-divider is-horizontal"></div> | ||
</mock:shadow-root> | ||
</atom-divider> | ||
`) | ||
}) | ||
}) | ||
|
||
it('should render with prop vertical', async () => { | ||
const page = await newSpecPage({ | ||
components: [AtomDivider], | ||
html: `<atom-divider type='vertical'/>`, | ||
}) | ||
|
||
await page.waitForChanges() | ||
|
||
expect(page.root).toEqualHtml(` | ||
<atom-divider type='vertical'> | ||
<mock:shadow-root> | ||
<div aria-hidden="" class="atom-divider is-vertical"></div> | ||
</mock:shadow-root> | ||
</atom-divider> | ||
`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Component, h, Prop } from '@stencil/core' | ||
|
||
@Component({ | ||
tag: 'atom-divider', | ||
styleUrl: 'divider.scss', | ||
shadow: true, | ||
}) | ||
export class AtomDivider { | ||
@Prop() type: 'horizontal' | 'vertical' = 'horizontal' | ||
|
||
render() { | ||
return <div class={`atom-divider is-${this.type}`} aria-hidden={true} /> | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/core/src/components/divider/stories/divider.args.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const DividerStoryArgs = { | ||
decorators: [], | ||
parameters: { | ||
actions: { | ||
handles: [], | ||
}, | ||
docs: { | ||
description: { | ||
component: | ||
'The Divider is a thin line that helps separate and group content in the interface. This component can also be used to define rhythm and order.', | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
type: { | ||
control: 'select', | ||
options: ['horizontal', 'vertical'], | ||
defaultValue: { summary: 'horizontal' }, | ||
description: | ||
'The type of the divider, will change your anatomy. The component can be used to separate content in two directions, vertical or horizontal.', | ||
}, | ||
}, | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/core/src/components/divider/stories/divider.core.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Meta, StoryObj } from '@storybook/web-components' | ||
import { html } from 'lit' | ||
|
||
import { DividerStoryArgs } from './divider.args' | ||
|
||
export default { | ||
title: 'Components/Divider', | ||
...DividerStoryArgs, | ||
} as Meta | ||
|
||
const createDivider = (args) => { | ||
return args.type === 'vertical' | ||
? html`<div style="height: 100px;"> | ||
<atom-divider type="${args.type}" /> | ||
</div>` | ||
: html`<atom-divider type="${args.type}" />` | ||
} | ||
|
||
export const Horizontal: StoryObj = { | ||
render: (args) => createDivider(args), | ||
args: { | ||
type: 'horizontal', | ||
}, | ||
} | ||
|
||
export const Vertical: StoryObj = { | ||
render: (args) => createDivider(args), | ||
args: { | ||
type: 'vertical', | ||
}, | ||
} |
38 changes: 38 additions & 0 deletions
38
packages/core/src/components/divider/stories/divider.react.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { AtomDivider } from '@juntossomosmais/atomium/react' | ||
import { Meta, StoryObj } from '@storybook/react' | ||
import React from 'react' | ||
|
||
import { DividerStoryArgs } from './divider.args' | ||
|
||
export default { | ||
title: 'Components/Divider', | ||
component: AtomDivider, | ||
...DividerStoryArgs, | ||
} as Meta | ||
|
||
const createDivider = (args) => | ||
args.type === 'vertical' ? ( | ||
<div | ||
style={{ | ||
height: '100px', | ||
}} | ||
> | ||
<AtomDivider type={args.type} /> | ||
</div> | ||
) : ( | ||
<AtomDivider type={args.type} /> | ||
) | ||
|
||
export const Horizontal: StoryObj = { | ||
render: (args) => createDivider(args), | ||
args: { | ||
type: 'horizontal', | ||
}, | ||
} | ||
|
||
export const Vertical: StoryObj = { | ||
render: (args) => createDivider(args), | ||
args: { | ||
type: 'vertical', | ||
}, | ||
} |
36 changes: 36 additions & 0 deletions
36
packages/core/src/components/divider/stories/divider.vue.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { AtomDivider } from '@juntossomosmais/atomium/vue' | ||
import { Meta, StoryObj } from '@storybook/vue3' | ||
|
||
import { DividerStoryArgs } from './divider.args' | ||
|
||
export default { | ||
title: 'Components/Divider', | ||
...DividerStoryArgs, | ||
} as Meta | ||
|
||
const createDivider = (args) => ({ | ||
components: { AtomDivider }, | ||
setup() { | ||
return { args } | ||
}, | ||
template: ` | ||
<div v-if="args.type === 'vertical'" style="height: 100px"> | ||
<AtomDivider :type="args.type" /> | ||
</div> | ||
<AtomDivider v-else :type="args.type" /> | ||
`, | ||
}) | ||
|
||
export const Horizontal: StoryObj = { | ||
render: (args) => createDivider(args), | ||
args: { | ||
type: 'horizontal', | ||
}, | ||
} | ||
|
||
export const Vertical: StoryObj = { | ||
render: (args) => createDivider(args), | ||
args: { | ||
type: 'vertical', | ||
}, | ||
} |