Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/column #10

Merged
merged 2 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/components/ButtonGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const ButtonGroup = ({ children, isCenter = false, gap = 10 }: ButtonGrou
}

return (
<div className={`flex ${centerButtons}`} style={style}>
<div className={`ui-buttongroup flex ${centerButtons}`} style={style}>
{children}
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const Card = ({ children, rounded, shadow, borderWidth, borderColor }: Ca
}

return (
<div className={`bg-white ${cardRounded} ${cardShadow}`} style={style}>
<div className={`ui-card bg-white ${cardRounded} ${cardShadow}`} style={style}>
<div className="py-5 px-7">{children}</div>
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions lib/components/CardGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ interface CardGroupProps {
gap?: number
}

export const CardGroup = ({ children, cols = 3, gap = 20 }: CardGroupProps) => {
export const CardGroup = ({ children, cols = 3, gap = 30 }: CardGroupProps) => {
// Inline style object to handle grid gap
const style = {
gridGap: gap ? gap : '',
}

return (
<div className={`grid ${gridColumns[cols]}`} style={style}>
<div className={`ui-cardgroup grid ${gridColumns[cols]}`} style={style}>
{children}
</div>
)
Expand Down
34 changes: 34 additions & 0 deletions lib/components/Column/Column.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react'
import type { Meta, StoryObj } from '@storybook/react'
import { Column } from '.'

const meta = {
title: 'Layouts/Column',
component: Column,
tags: ['autodocs'],
} satisfies Meta<typeof Column>

export default meta
type Story = StoryObj<typeof meta>

export const Primary: Story = {
render: (args) => (
<Column {...args}>
<Column.Content>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus gravida orci elit, at consectetur lectus
iaculis vel. Cras non fringilla velit, a posuere felis. Mauris faucibus dui ultricies ultrices luctus. Aliquam
erat volutpat. Vestibulum imperdiet, enim non elementum pulvinar, lacus quam vestibulum eros, ut eleifend sem
dui ut quam.
</p>
</Column.Content>
<Column.Content>
<p>
Nam facilisis pulvinar ligula nec cursus. Mauris ut tempor enim. Nullam sodales eros ut velit ullamcorper
fringilla. Fusce a sem est. Vivamus eleifend accumsan pellentesque. Pellentesque in ante urna. Nullam finibus
sed nunc ac volutpat. Maecenas lacinia justo a arcu tempor, ac tempor magna faucibus.
</p>
</Column.Content>
</Column>
),
}
11 changes: 11 additions & 0 deletions lib/components/Column/content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

export interface ColumnContentProps {
children: React.ReactNode
}

export const ColumnContent = ({ children }: ColumnContentProps) => {
return <div>{children}</div>
}

ColumnContent.displayName = 'Column.Content'
27 changes: 27 additions & 0 deletions lib/components/Column/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { gridColumns } from '../../utils/tailwindProps'
import { ColumnContent } from './content'

type ColumnKeys = keyof typeof gridColumns

interface ColumnProps {
children?: React.ReactNode
cols?: ColumnKeys
gap?: number
}

export const ColumnContainer = ({ children, cols = 2, gap = 30 }: ColumnProps) => {
// Inline style object to handle grid gap
const style = {
gridGap: gap ? gap : '',
}

return (
<div className={`ui-column grid ${gridColumns[cols]}`} style={style}>
{children}
</div>
)
}

export const Column = Object.assign(ColumnContainer, {
Content: ColumnContent,
})
1 change: 1 addition & 0 deletions lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export { Button } from './components/Button'
export { ButtonGroup } from './components/ButtonGroup'
export { Card } from './components/Card'
export { CardGroup } from './components/CardGroup'
export { Column } from './components/Column'
Loading