-
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(core): add container component (#471)
- Loading branch information
1 parent
94bb01b
commit edd6d08
Showing
9 changed files
with
227 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,12 @@ | ||
@import '~@atomium/scss-utils/index'; | ||
|
||
:host { | ||
display: block; | ||
margin-left: auto; | ||
margin-right: auto; | ||
max-width: var(--screen-max-container); | ||
} | ||
|
||
:host(.has-padding) { | ||
padding: var(--spacing-base); | ||
} |
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,41 @@ | ||
import { newSpecPage } from '@stencil/core/testing' | ||
|
||
import { AtomContainer } from './container' | ||
|
||
describe('atom-container', () => { | ||
it('should render an atom-container element', async () => { | ||
const page = await newSpecPage({ | ||
components: [AtomContainer], | ||
html: `<atom-container>Content</atom-container>`, | ||
}) | ||
|
||
await page.waitForChanges() | ||
|
||
expect(page?.root).toEqualHtml(` | ||
<atom-container class="has-padding"> | ||
<mock:shadow-root> | ||
<slot></slot> | ||
</mock:shadow-root> | ||
Content | ||
</atom-container> | ||
`) | ||
}) | ||
|
||
it('should render an atom-container element without padding', async () => { | ||
const page = await newSpecPage({ | ||
components: [AtomContainer], | ||
html: `<atom-container has-padding="false">Content</atom-container>`, | ||
}) | ||
|
||
await page.waitForChanges() | ||
|
||
expect(page?.root).toEqualHtml(` | ||
<atom-container has-padding="false"> | ||
<mock:shadow-root> | ||
<slot></slot> | ||
</mock:shadow-root> | ||
Content | ||
</atom-container> | ||
`) | ||
}) | ||
}) |
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,18 @@ | ||
import { Component, Host, Prop, h } from '@stencil/core' | ||
|
||
@Component({ | ||
tag: 'atom-container', | ||
styleUrl: 'container.scss', | ||
shadow: true, | ||
}) | ||
export class AtomContainer { | ||
@Prop() hasPadding = true | ||
|
||
render() { | ||
return ( | ||
<Host class={{ 'has-padding': this.hasPadding }}> | ||
<slot></slot> | ||
</Host> | ||
) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/core/src/components/container/stories/container.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,25 @@ | ||
export const ContainerStoryArgs = { | ||
decorators: [], | ||
parameters: { | ||
actions: { | ||
handles: [], | ||
}, | ||
docs: { | ||
description: { | ||
component: | ||
'Container is a component that wraps content in application using a max-width and padding to define the width of the content.', | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
hasPadding: { | ||
control: 'boolean', | ||
defaultValue: { summary: true }, | ||
description: 'If false the container will not have padding', | ||
}, | ||
}, | ||
} | ||
|
||
export const ContainerComponentArgs = { | ||
hasPadding: true, | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/core/src/components/container/stories/container.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,33 @@ | ||
import { Meta, StoryObj } from '@storybook/web-components' | ||
import { html } from 'lit' | ||
|
||
import { ContainerComponentArgs, ContainerStoryArgs } from './container.args' | ||
|
||
import './container.css' | ||
|
||
export default { | ||
title: 'Components/Container', | ||
...ContainerStoryArgs, | ||
} as Meta | ||
|
||
const createContainer = (args) => { | ||
return html` | ||
<atom-container class="wrapper" has-padding="${args.hasPadding}"> | ||
<section> | ||
<h1 class="title">Container Title</h1> | ||
<p class="text"> | ||
This is a sample content inside the container to demonstrate its | ||
behavior and appearance with and without padding. Adjust the controls | ||
to see how it changes. | ||
</p> | ||
</section> | ||
</atom-container> | ||
` | ||
} | ||
|
||
export const Default: StoryObj = { | ||
render: (args) => createContainer(args), | ||
args: { | ||
...ContainerComponentArgs, | ||
}, | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/core/src/components/container/stories/container.css
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 @@ | ||
.wrapper { | ||
background-color: var(--color-neutral-light-5) | ||
} | ||
|
||
.title { | ||
color: var(--color-neutral-dark-1); | ||
font: var(--title-headline-xsmall); | ||
letter-spacing: var(--title-headline-xsmall-letter); | ||
margin: 0 0 var(--spacing-xxsmall); | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/core/src/components/container/stories/container.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,31 @@ | ||
import { AtomContainer } from '@juntossomosmais/atomium/react' | ||
import { Meta, StoryObj } from '@storybook/react' | ||
import React from 'react' | ||
|
||
import { ContainerComponentArgs, ContainerStoryArgs } from './container.args' | ||
|
||
import './container.css' | ||
|
||
export default { | ||
title: 'Components/Container', | ||
component: AtomContainer, | ||
...ContainerStoryArgs, | ||
} as Meta | ||
|
||
const createContainer = (args) => ( | ||
<AtomContainer className='wrapper' hasPadding={args.hasPadding}> | ||
<h1 className='title'>Container Title</h1> | ||
<p className='text'> | ||
This is a sample content inside the container to demonstrate its behavior | ||
and appearance with and without padding. Adjust the controls to see how it | ||
changes. | ||
</p> | ||
</AtomContainer> | ||
) | ||
|
||
export const Default: StoryObj = { | ||
render: (args) => createContainer(args), | ||
args: { | ||
...ContainerComponentArgs, | ||
}, | ||
} |
42 changes: 42 additions & 0 deletions
42
packages/core/src/components/container/stories/container.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,42 @@ | ||
import { AtomContainer } from '@juntossomosmais/atomium/vue' | ||
import { Meta, StoryObj } from '@storybook/vue3' | ||
|
||
import { ContainerStoryArgs } from './container.args' | ||
|
||
import './container.css' | ||
|
||
export default { | ||
title: 'Components/Container', | ||
...ContainerStoryArgs, | ||
} as Meta | ||
|
||
const createContainer = (args) => ({ | ||
components: { AtomContainer }, | ||
setup() { | ||
return { args } | ||
}, | ||
template: ` | ||
<AtomContainer class="wrapper" hasPadding="${args.hasPadding}"> | ||
<h1 class="title">Container Title</h1> | ||
<p class="text"> | ||
This is a sample content inside the container to demonstrate its behavior | ||
and appearance with and without padding. Adjust the controls to see how it | ||
changes. | ||
</p> | ||
</AtomContainer> | ||
`, | ||
}) | ||
|
||
export const Default: StoryObj = { | ||
render: (args) => createContainer(args), | ||
args: { | ||
hasPadding: true, | ||
}, | ||
} | ||
|
||
export const NoPadding: StoryObj = { | ||
render: (args) => createContainer(args), | ||
args: { | ||
hasPadding: false, | ||
}, | ||
} |