Skip to content

Commit

Permalink
refactor: make the props and css correct by getting them from the var…
Browse files Browse the repository at this point in the history
…iables
  • Loading branch information
HamzaAmar committed Nov 13, 2024
1 parent 6973b2c commit fcc2015
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/accordion/accordion.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ReactElement, Dispatch, SetStateAction } from 'react'
import { Color, Corner, Size, Variant } from '../../types'

export interface AccordionProps {
type?: 'single' | 'multiple'
multiple?: boolean
collapsible?: boolean
color?: Color
variant?: Variant
Expand Down
19 changes: 4 additions & 15 deletions packages/pillar-core/src/core/accordion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import type {
///////////////////////////////////////////////////////////////////////////////////////////////////
*/

function useAccordion({ type, collapsible }: AccordionProps) {
const [active, setActive] = useState<Value | Value[]>(type === 'multiple' ? [] : -1)
function useAccordion({ multiple, collapsible }: AccordionProps) {
const [active, setActive] = useState<Value | Value[]>(multiple ? [] : -1)
const isOpen = (value: Value) => (Array.isArray(active) ? active.includes(value) : active === value)

function toggleAccordion(currentIndex: Value) {
Expand Down Expand Up @@ -61,21 +61,10 @@ const [AccordionProvider, useAccordionContext] = context<AccordionContextProps>(

export const Accordion = forwardRef(
(
{
children,
type = 'single',
collapsible,
color = 'B',
variant,
size = '5',
corner = '0',
separate,
className,
...rest
},
{ children, multiple, collapsible, color = 'B', variant, size = '5', corner = '0', separate, className, ...rest },
forwardedRef
) => {
const state = useAccordion({ type, collapsible })
const state = useAccordion({ multiple, collapsible })

const classNames = cx(`ac-`, {
[`C-${color}`]: color,
Expand Down
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/alert/_alert.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
border: 1px solid transparent;
/* Default Value set by the Client */
border-radius: var(--al-rad, 0);
font-size: var(--al-size, 1rem);
font-size: var(--al-size, var(--F5));
}

.al-C {
Expand Down
4 changes: 3 additions & 1 deletion packages/pillar-core/src/core/avatar/_avatar.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
linear-gradient(var(--av-b), var(--av-b)) content-box,
linear-gradient(var(--B1), var(--B1)) padding-box;
min-width: var(--eq-s);
/* aspect-ratio: 1; */
max-height: var(--eq-s);

/* Default Value set by the Client */
border-radius: var(--avatar-rad, 10em);
font-size: var(--avatar-size, 1rem);
font-size: var(--avatar-size, var(--F5));

& > * {
border-radius: inherit;
Expand Down
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/blockquote/_blockquote.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
avatars are provided, they will override these properties.
*/
border-radius: var(--blockquote-rad, 0.25em);
font-size: var(--blockquote-size, 1rem);
font-size: var(--blockquote-size, var(--F5));

& cite {
display: block;
Expand Down
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/button/_button.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
avatars are provided, they will override these properties.
*/
border-radius: var(--bu-rad, 0.25em);
font-size: var(--bu-size, 0.875rem);
font-size: var(--bu-size, var(--F4));
text-transform: var(--bu-transform, capitalize);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/button/button.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Color, Size, Corner, Variant, Direction, Transform, CornerHand } f
type Position = 'start' | 'end'
type State = 'idle' | 'loading'

type ButtonVariant = Variant | 'link' | 'shadow'
type ButtonVariant = Variant | 'link'

interface BaseButton {
color?: Color
Expand Down
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/checkbox/_checkbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
color: var(--text-8);
display: flex;
gap: var(--S3);
align-items: center;
align-items: start;

/* Default Value by The Client */
font-size: var(--checkbox-size, 1rem);
Expand Down
4 changes: 2 additions & 2 deletions packages/pillar-core/src/core/chips/_chips.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.ci- {
max-width: 35ch;
padding: 0.125em 0.25em;
padding: 0.125em;

/*
These properties serve as fallbacks. If the corresponding utility functions are
unavailable, these properties take priority. However, if specific props related to
avatars are provided, they will override these properties.
*/
border-radius: var(--chip-rad, 0.25em);
font-size: var(--chip-size, 0.875rem);
font-size: var(--chip-size, var(--F3));
text-transform: var(--chip-transform, capitalize);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/code/_code.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
Code are provided, they will override these properties.
*/
border-radius: var(--code-rad, 0.125em);
font-size: var(--code-size, 0.85rem);
font-size: var(--code-size, var(--F4));
text-transform: var(--code-transform, capitalize);
}
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/pagination/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Item = forwardRef((props, forwardedRef) => {
const {
active = 1,
children,
variant = context?.variant ?? 'outline',
variant = context?.variant ?? 'soft',
color = context?.color ?? 'b',
size = context?.size ?? '4',
corner = context?.corner ?? '2',
Expand Down
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/spinner/_spinner.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
unavailable, these properties take priority. However, if specific props related to
avatars are provided, they will override these properties.
*/
font-size: var(--spinner-size, 1em);
font-size: var(--spinner-size, var(--F5));

/* &:is(::before, ::after) { */
&::before,
Expand Down
2 changes: 1 addition & 1 deletion packages/pillar-core/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Corner = '0' | SharedSize | 'circle' | 'full'
* @typedef {Corner} Corner
*/

type Variant = 'solid' | 'outline' | 'soft' | 'text' | 'mixed' | undefined
type Variant = 'shadow' | 'solid' | 'outline' | 'soft' | 'text' | 'mixed' | undefined

/**
* Represents the color of a component.
Expand Down

0 comments on commit fcc2015

Please sign in to comment.