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

fix: start implementing css principles #2313

Merged
merged 29 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f2d242d
fix: start implementing css principles
eirikbacker Aug 22, 2024
f1449ae
fix: clean-up
eirikbacker Aug 23, 2024
9938811
Merge branch 'next' into feat/css-preparations-part-1
eirikbacker Aug 23, 2024
aac98c5
fix: link icon adjustment
eirikbacker Aug 23, 2024
f4ed839
fix: cleanup
eirikbacker Aug 23, 2024
9fe2517
fix: responsive medium button
eirikbacker Aug 23, 2024
5247f96
fix: pr review
eirikbacker Aug 27, 2024
f1d780c
Merge branch 'next' into feat/css-preparations-part-1
eirikbacker Aug 27, 2024
fe4fd53
fix: move to data-ds attributes
eirikbacker Aug 27, 2024
98bf23d
chore: update button usage
eirikbacker Aug 27, 2024
5a6efeb
fix(Button): remove icon prop
eirikbacker Aug 27, 2024
02e6be9
chore: merge in next
eirikbacker Sep 2, 2024
aa8a0bd
fix: only one divider variant
eirikbacker Sep 2, 2024
0f91d82
fix: adjust icon only button
eirikbacker Sep 2, 2024
c246a95
fix: support right-to-left text
eirikbacker Sep 2, 2024
5f61853
Update packages/react/src/components/Alert/Alert.test.tsx
eirikbacker Sep 4, 2024
1d69e50
fix: pr review
eirikbacker Sep 4, 2024
f1822ca
docs: update button icon
eirikbacker Sep 4, 2024
39daab2
fix: typo
eirikbacker Sep 4, 2024
328c154
Merge branch 'next' into feat/css-preparations-part-1
eirikbacker Sep 4, 2024
590aec9
fix: tests
eirikbacker Sep 4, 2024
2a700a9
fix(Button): remove fullwidth
eirikbacker Sep 4, 2024
67a402e
Merge branch 'next' into feat/css-preparations-part-1
eirikbacker Sep 4, 2024
ef72733
Update packages/css/button.css
eirikbacker Sep 6, 2024
90366f6
fix: pr revieq
eirikbacker Sep 6, 2024
d94cef7
fix: undo pr comment
eirikbacker Sep 6, 2024
b65c314
fix: remove ds prefix from data attributes
eirikbacker Sep 6, 2024
f181b1a
fix hide button spinner
eirikbacker Sep 6, 2024
4a7ae66
Create healthy-apples-explode.md
eirikbacker Sep 6, 2024
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 apps/storefront/components/SidebarMenu/SidebarMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const SidebarMenu = ({ routerPath }: SidebarMenuProps) => {
<>
<Button
className={classes.toggleBtn}
fullWidth
fill
size='md'
color='neutral'
variant='secondary'
Expand Down
4 changes: 2 additions & 2 deletions apps/storybook/docs-components/Information/Information.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const texts: Record<Texts, { description: string; title?: string }> = {
},
};

const getSeverity = (text: Texts): AlertProps['severity'] => {
const getColor = (text: Texts): AlertProps['color'] => {
switch (text) {
case 'deprecated':
return 'danger';
Expand All @@ -50,7 +50,7 @@ export const Information = ({ text, description }: InformationProps) => {
const textData = texts[text];

return (
<Alert className={classes.container} severity={getSeverity(text)}>
<Alert className={classes.container} color={getColor(text)}>
{textData.title && (
<Heading level={2} size='xs' spacing>
{textData.title}
Expand Down
10 changes: 5 additions & 5 deletions apps/theme/components/Previews/Components/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const Components = () => {
Glemt passord?
</Link>
</Tooltip>
<Button fullWidth size='sm' className={classes.userBtn}>
<Button fill size='sm' className={classes.userBtn}>
Opprett ny bruker
</Button>
</div>
Expand Down Expand Up @@ -375,17 +375,17 @@ export const Components = () => {
</Accordion.Root>
</div>
<div className={cl(classes.card, classes.alert)}>
<Alert severity='info'>
<Alert color='info'>
Dette er informasjon som du bør lese for å forstå hva som skjer
</Alert>
<Alert severity='warning'>
<Alert color='warning'>
Dette er en advarsel om at noe kan gå galt hvis du ikke følger med
</Alert>
<Alert severity='danger'>
<Alert color='danger'>
Dette er en melding om at noe har gått galt og du bør gjøre noe med
det
</Alert>
<Alert severity='success'>
<Alert color='success'>
Dette er en melding om at noe har gått bra og du kan fortsette
</Alert>
</div>
Expand Down
104 changes: 52 additions & 52 deletions packages/css/alert.css
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
.ds-alert {
--dsc-alert-background: var(--ds-color-info-surface-default);
--dsc-alert-border-color: var(--ds-color-info-border-strong);
--dsc-alert-border-radius: min(1rem, var(--ds-border-radius-md));
--dsc-alert-color: var(--ds-color-neutral-text-default);
--dsc-alert-icon-color: var(--ds-color-neutral-text-subtle);
--dsc-alert-gap: var(--ds-spacing-2);
--dsc-alert-icon-color: var(--ds-color-info-text-subtle);
--dsc-alert-icon-size: var(--ds-sizing-7);
--dsc-alert-background: var(--ds-color-info-surface-default);
--dsc-alert-icon-url: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' d='M3.25 4A.75.75 0 0 1 4 3.25h16a.75.75 0 0 1 .75.75v16a.75.75 0 0 1-.75.75H4a.75.75 0 0 1-.75-.75zM11 7.75a1 1 0 1 1 2 0 1 1 0 0 1-2 0m-1.25 3a.75.75 0 0 1 .75-.75H12a.75.75 0 0 1 .75.75v4.75h.75a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1 0-1.5h.75v-4h-.75a.75.75 0 0 1-.75-.75'/%3E%3C/svg%3E");
--dsc-alert-padding: var(--ds-spacing-6);

border: 1px solid var(--dsc-alert-border-color);
border-radius: var(--dsc-alert-border-radius);
background: var(--dsc-alert-background);
border-radius: var(--dsc-alert-border-radius);
border: 1px solid var(--dsc-alert-border-color);
color: var(--dsc-alert-color);
padding: var(--dsc-alert-padding);
display: grid;
grid-auto-flow: column;
grid-auto-columns: min-content auto;
gap: var(--ds-spacing-2);
}

.ds-alert__icon {
height: var(--dsc-alert-icon-size);
width: var(--dsc-alert-icon-size);
color: var(--dsc-alert-icon-color);
}

.ds-alert__content {
display: flex;
flex-direction: column;
}
padding-left: calc(var(--dsc-alert-padding) + var(--dsc-alert-icon-size) + var(--dsc-alert-gap));

.ds-alert--info {
--dsc-alert-border-color: var(--ds-color-info-border-strong);
--dsc-alert-icon-color: var(--ds-color-info-text-subtle);
--dsc-alert-background: var(--ds-color-info-surface-default);
}

.ds-alert--warning {
--dsc-alert-border-color: var(--ds-color-warning-border-default);
--dsc-alert-icon-color: var(--ds-color-warning-text-subtle);
--dsc-alert-background: var(--ds-color-warning-surface-default);
}
& > :is(h1,h2,h3,h4,h5,h6):first-child::before, /* If Alert starts with Heading, align icon to this */
&:not(:has(> :is(h1,h2,h3,h4,h5,h6):first-child))::before /* If there is no Heading, align icon to Alert itself */ {
background-color: var(--dsc-alert-icon-color);
content: '';
display: block;
height: var(--dsc-alert-icon-size);
mask: var(--dsc-alert-icon-url) center/contain no-repeat;
width: var(--dsc-alert-icon-size);
position: absolute;
translate: /* Using translate instead of top/left to avoid position: relative or display: grid on alert */
calc((var(--dsc-alert-icon-size) + var(--dsc-alert-gap)) * -1)
calc(.5lh - var(--dsc-alert-icon-size) / 2); /* Center icon to line height */
}

.ds-alert--success {
--dsc-alert-border-color: var(--ds-color-success-border-default);
--dsc-alert-icon-color: var(--ds-color-success-text-subtle);
--dsc-alert-background: var(--ds-color-success-surface-default);
}
/**
* Colors
*/
&[data-color="warning"] {
--dsc-alert-border-color: var(--ds-color-warning-border-default);
--dsc-alert-icon-color: var(--ds-color-warning-text-subtle);
--dsc-alert-background: var(--ds-color-warning-surface-default);
--dsc-alert-icon-url: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2.25a.75.75 0 0 1 .66.39l9.52 17.25a.75.75 0 0 1-.65 1.11H2.47a.75.75 0 0 1-.65-1.11l9.52-17.25a.75.75 0 0 1 .66-.39m0 6.5a.75.75 0 0 1 .75.75v4a.75.75 0 0 1-1.5 0v-4a.75.75 0 0 1 .75-.75m-1 7.75a1 1 0 1 1 2 0 1 1 0 0 1-2 0'/%3E%3C/svg%3E");
}

.ds-alert--danger {
--dsc-alert-border-color: var(--ds-color-danger-border-default);
--dsc-alert-icon-color: var(--ds-color-danger-text-subtle);
--dsc-alert-background: var(--ds-color-danger-surface-default);
}
&[data-color="success"] {
--dsc-alert-background: var(--ds-color-success-surface-default);
--dsc-alert-border-color: var(--ds-color-success-border-default);
--dsc-alert-icon-color: var(--ds-color-success-text-subtle);
--dsc-alert-icon-url: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 21.75a9.75 9.75 0 1 0 0-19.5 9.75 9.75 0 0 0 0 19.5m4.95-12.47a.81.81 0 0 0-1.24-1.05l-5.39 6.36-2.62-2.62a.81.81 0 0 0-1.15 1.15l3.25 3.25a.81.81 0 0 0 1.2-.05z'/%3E%3C/svg%3E");
}

.ds-alert--sm {
--dsc-alert-padding: var(--ds-spacing-5);
--dsc-alert-icon-size: var(--ds-sizing-6);
}
&[data-color="danger"] {
--dsc-alert-background: var(--ds-color-danger-surface-default);
--dsc-alert-border-color: var(--ds-color-danger-border-default);
--dsc-alert-icon-color: var(--ds-color-danger-text-subtle);
--dsc-alert-icon-url: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M7.74 2.47a.75.75 0 0 1 .53-.22h7.46a.75.75 0 0 1 .53.22l5.27 5.27c.14.14.22.33.22.53v7.46a.75.75 0 0 1-.22.53l-5.27 5.27a.75.75 0 0 1-.53.22H8.27a.75.75 0 0 1-.53-.22l-5.27-5.27a.75.75 0 0 1-.22-.53V8.27a.75.75 0 0 1 .22-.53zm1.29 5.5a.75.75 0 0 0-1.06 1.06L10.94 12l-2.97 2.97a.75.75 0 1 0 1.06 1.06L12 13.06l2.97 2.97a.75.75 0 1 0 1.06-1.06L13.06 12l2.97-2.97a.75.75 0 0 0-1.06-1.06L12 10.94z'/%3E%3C/svg%3E");
}

.ds-alert--md {
--dsc-alert-padding: var(--ds-spacing-6);
--dsc-alert-icon-size: var(--ds-sizing-7);
}
/**
* Sizes
*/
&[data-size="sm"] {
--dsc-alert-padding: var(--ds-spacing-5);
--dsc-alert-icon-size: var(--ds-sizing-6);
}

.ds-alert--lg {
--dsc-alert-padding: var(--ds-spacing-7);
--dsc-alert-icon-size: var(--ds-sizing-8);
&[data-size="lg"] {
--dsc-alert-padding: var(--ds-spacing-7);
--dsc-alert-icon-size: var(--ds-sizing-8);
}
}
Loading
Loading