diff --git a/packages/core/src/components.d.ts b/packages/core/src/components.d.ts index bb19f840a..8fefe2ced 100644 --- a/packages/core/src/components.d.ts +++ b/packages/core/src/components.d.ts @@ -77,6 +77,9 @@ export namespace Components { "sizeMd"?: string; "sizeSm"?: string; } + interface AtomContainer { + "hasPadding": boolean; + } interface AtomGrid { "fixed"?: boolean; } @@ -339,6 +342,12 @@ declare global { prototype: HTMLAtomColElement; new (): HTMLAtomColElement; }; + interface HTMLAtomContainerElement extends Components.AtomContainer, HTMLStencilElement { + } + var HTMLAtomContainerElement: { + prototype: HTMLAtomContainerElement; + new (): HTMLAtomContainerElement; + }; interface HTMLAtomGridElement extends Components.AtomGrid, HTMLStencilElement { } var HTMLAtomGridElement: { @@ -451,6 +460,7 @@ declare global { "atom-carousel-item": HTMLAtomCarouselItemElement; "atom-chip": HTMLAtomChipElement; "atom-col": HTMLAtomColElement; + "atom-container": HTMLAtomContainerElement; "atom-grid": HTMLAtomGridElement; "atom-icon": HTMLAtomIconElement; "atom-input": HTMLAtomInputElement; @@ -531,6 +541,9 @@ declare namespace LocalJSX { "sizeMd"?: string; "sizeSm"?: string; } + interface AtomContainer { + "hasPadding"?: boolean; + } interface AtomGrid { "fixed"?: boolean; } @@ -699,6 +712,7 @@ declare namespace LocalJSX { "atom-carousel-item": AtomCarouselItem; "atom-chip": AtomChip; "atom-col": AtomCol; + "atom-container": AtomContainer; "atom-grid": AtomGrid; "atom-icon": AtomIcon; "atom-input": AtomInput; @@ -721,6 +735,7 @@ declare module "@stencil/core" { "atom-carousel-item": LocalJSX.AtomCarouselItem & JSXBase.HTMLAttributes; "atom-chip": LocalJSX.AtomChip & JSXBase.HTMLAttributes; "atom-col": LocalJSX.AtomCol & JSXBase.HTMLAttributes; + "atom-container": LocalJSX.AtomContainer & JSXBase.HTMLAttributes; "atom-grid": LocalJSX.AtomGrid & JSXBase.HTMLAttributes; "atom-icon": LocalJSX.AtomIcon & JSXBase.HTMLAttributes; "atom-input": LocalJSX.AtomInput & JSXBase.HTMLAttributes; diff --git a/packages/core/src/components/container/container.scss b/packages/core/src/components/container/container.scss new file mode 100644 index 000000000..0d9956186 --- /dev/null +++ b/packages/core/src/components/container/container.scss @@ -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); +} diff --git a/packages/core/src/components/container/container.spec.ts b/packages/core/src/components/container/container.spec.ts new file mode 100644 index 000000000..6bd4b5f2b --- /dev/null +++ b/packages/core/src/components/container/container.spec.ts @@ -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: `Content`, + }) + + await page.waitForChanges() + + expect(page?.root).toEqualHtml(` + + + + + Content + + `) + }) + + it('should render an atom-container element without padding', async () => { + const page = await newSpecPage({ + components: [AtomContainer], + html: `Content`, + }) + + await page.waitForChanges() + + expect(page?.root).toEqualHtml(` + + + + + Content + + `) + }) +}) diff --git a/packages/core/src/components/container/container.tsx b/packages/core/src/components/container/container.tsx new file mode 100644 index 000000000..daa894af2 --- /dev/null +++ b/packages/core/src/components/container/container.tsx @@ -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 ( + + + + ) + } +} diff --git a/packages/core/src/components/container/stories/container.args.ts b/packages/core/src/components/container/stories/container.args.ts new file mode 100644 index 000000000..3328b69ab --- /dev/null +++ b/packages/core/src/components/container/stories/container.args.ts @@ -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, +} diff --git a/packages/core/src/components/container/stories/container.core.stories.tsx b/packages/core/src/components/container/stories/container.core.stories.tsx new file mode 100644 index 000000000..c0cd016d4 --- /dev/null +++ b/packages/core/src/components/container/stories/container.core.stories.tsx @@ -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` + +
+

Container Title

+

+ 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. +

+
+
+ ` +} + +export const Default: StoryObj = { + render: (args) => createContainer(args), + args: { + ...ContainerComponentArgs, + }, +} diff --git a/packages/core/src/components/container/stories/container.css b/packages/core/src/components/container/stories/container.css new file mode 100644 index 000000000..6603e719e --- /dev/null +++ b/packages/core/src/components/container/stories/container.css @@ -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); +} diff --git a/packages/core/src/components/container/stories/container.react.stories.tsx b/packages/core/src/components/container/stories/container.react.stories.tsx new file mode 100644 index 000000000..9567d31bc --- /dev/null +++ b/packages/core/src/components/container/stories/container.react.stories.tsx @@ -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) => ( + +

Container Title

+

+ 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. +

+
+) + +export const Default: StoryObj = { + render: (args) => createContainer(args), + args: { + ...ContainerComponentArgs, + }, +} diff --git a/packages/core/src/components/container/stories/container.vue.stories.tsx b/packages/core/src/components/container/stories/container.vue.stories.tsx new file mode 100644 index 000000000..b17e3cee9 --- /dev/null +++ b/packages/core/src/components/container/stories/container.vue.stories.tsx @@ -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: ` + +

Container Title

+

+ 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. +

+
+ `, +}) + +export const Default: StoryObj = { + render: (args) => createContainer(args), + args: { + hasPadding: true, + }, +} + +export const NoPadding: StoryObj = { + render: (args) => createContainer(args), + args: { + hasPadding: false, + }, +}