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

chore: make sure there is always on main color #3009

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}

.colorPreview {
height: 120px;
height: 60px;
width: 100%;
border-radius: 8px;
}
Expand All @@ -66,10 +66,6 @@
display: block;
}

.hide {
display: none;
}

.desc {
color: var(--ds-color-neutral-text-subtle);
margin-bottom: 16px;
Expand Down
35 changes: 23 additions & 12 deletions apps/theme/components/Sidebar/ColorPane/ColorPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import {
Heading,
Paragraph,
Textfield,
Tooltip,
} from '@digdir/designsystemet-react';
import { ChevronLeftIcon, TrashIcon } from '@navikt/aksel-icons';
import { ColorPicker, type IColor } from 'react-color-palette';
import { useThemeStore } from '../../../store';

import cl from 'clsx/lite';
import classes from './ColorPane.module.css';
Expand Down Expand Up @@ -35,6 +37,8 @@ export const ColorPane = ({
onRemove,
colorType,
}: ColorPaneProps) => {
const mainColors = useThemeStore((state) => state.colors.main);

const getHeading = () => {
const t = colorType === 'main' ? 'hovedfarge' : 'støttefarge';
return type === 'addColor' ? 'Legg til ' + t : 'Rediger farge';
Expand All @@ -53,19 +57,26 @@ export const ColorPane = ({
>
<ChevronLeftIcon title='a11y-title' fontSize='1.5rem' /> Gå tilbake
</Button>
<Button
data-size='sm'
variant='tertiary'
data-color='danger'
onClick={() => onRemove()}
className={cl(
classes.removeBtn,
(type !== 'editColor' || colorType === 'neutral') && classes.hide,
)}
<Tooltip
content='Du må ha minst en hovedfarge'
hidden={colorType !== 'main' || mainColors.length > 1}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this also use disableRemoveButton? It should only show when button is disabled no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, forgot to change it here. Nice catch

>
Fjern farge
<TrashIcon title='a11y-title' fontSize='1.5rem' />
</Button>
<Button
data-size='sm'
variant='tertiary'
data-color='danger'
onClick={() => {
if (colorType === 'main' && mainColors.length === 1) return;
mimarz marked this conversation as resolved.
Show resolved Hide resolved
onRemove();
}}
className={cl(classes.removeBtn)}
hidden={type !== 'editColor' || colorType === 'neutral'}
aria-disabled={colorType === 'main' && mainColors.length === 1}
>
Fjern farge
<TrashIcon title='søppelkasse' fontSize='1.5rem' />
</Button>
</Tooltip>
</div>
<Heading data-size='xs' className={classes.title}>
{getHeading()}
Expand Down
3 changes: 2 additions & 1 deletion apps/theme/components/Sidebar/Sidebar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
position: relative;
z-index: 100;
right: 20px;
top: 20px;
top: -20px;
background-color: var(--ds-color-neutral-background-default);
border: 1px solid var(--ds-color-neutral-border-subtle);
box-shadow: 0px 0px 60px 10px rgba(0, 0, 0, 0.1);
Expand All @@ -26,6 +26,7 @@
.sticky {
position: fixed;
margin-top: 0;
top: 20px;
}

.tabContent {
Expand Down
Loading