Skip to content

Commit

Permalink
refactor: improvement into the core component (#104)
Browse files Browse the repository at this point in the history
- Fix issue in the paper component
- Improve the grid component
- Add new alignment css utilities
  • Loading branch information
HamzaAmar committed Nov 21, 2024
1 parent 58e7baa commit 9ebdb2a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/pillar-core/src/core/grid/grid.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface GridProps {
children: ReactNode
items?: Items
justify?: Justify
justifyItem?: Items
alignContent?: Justify | 'baseline'
gap?: Size
cols?: GridBaseProps
rows?: GridBaseProps
Expand Down
20 changes: 17 additions & 3 deletions packages/pillar-core/src/core/grid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const GridItem = forwardRef(
])

const classNames = cx(`${cls}`, {
className: className,
[className!]: className,
})

return (
Expand Down Expand Up @@ -61,7 +61,20 @@ GridItem.displayName = 'GridItem'

export const Grid = forwardRef(
(
{ gap, cols = {}, rows = {}, items, justify, children, style, as: Tag = 'div', className, ...rest },
{
gap,
cols = {},
rows = {},
items,
justify,
justifyItem,
alignContent,
children,
style,
as: Tag = 'div',
className,
...rest
},
forwardedRef
) => {
const [styles, cls] = getCSS([
Expand All @@ -81,10 +94,11 @@ export const Grid = forwardRef(

const classNames = cx(`gr- ${cls}`, {
[`Ajc-${justify}`]: justify,
[`Aji-${justifyItem}`]: justifyItem,
[`Aai-${items}`]: items,
[`Aac-${alignContent}`]: alignContent,
[`Sg-${gap}`]: gap,
[className!]: className,
className: className,
})

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/paper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const Paper = forwardRef(
[className!]: className,
})

const bg = background ? { '--pbg': `var(--${background}` } : {}
const bg = background ? { '--pbg': `var(--${background})` } : {}

return (
<Tag style={{ ...bg, ...style } as CSSProperties} className={classNames} ref={ref} {...rest}>
Expand Down
18 changes: 16 additions & 2 deletions packages/pillar-core/src/css/utilities/_alignment.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

/* Align Item Section Style Start */

.Aji-start {
justify-items: start;
}
.Aji-center {
justify-items: center;
}
Expand Down Expand Up @@ -62,12 +65,23 @@
align-items: start;
}

/* // Align Content Section Style Start */
/* Align Content Section Style Start */

.Aac-start {
align-content: start;
}
.Aac-center {
align-content: center;
}
.Aac-end {
align-content: end;
}

.Aac-baseline {
align-content: baseline;
}
.Aac-stretch {
align-content: stretch;
}
.Aac-between {
align-content: space-between;
}
Expand Down

0 comments on commit 9ebdb2a

Please sign in to comment.