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

feat!: Allow additional background colours for Avatar and remove dark blue option #1257

Merged
merged 4 commits into from
Jun 12, 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
35 changes: 30 additions & 5 deletions packages/css/src/components/avatar/avatar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
vertical-align: middle; /* Remove ‘phantom’ white space when image doesn’t load */
}

.ams-avatar--black {
background-color: var(--ams-avatar-black-background-color);
color: var(--ams-avatar-black-color);
}

.ams-avatar--blue {
background-color: var(--ams-avatar-blue-background-color);
color: var(--ams-avatar-blue-color);
}

.ams-avatar--dark-blue {
background-color: var(--ams-avatar-dark-blue-background-color);
color: var(--ams-avatar-dark-blue-color);
}

.ams-avatar--dark-green {
background-color: var(--ams-avatar-dark-green-background-color);
color: var(--ams-avatar-dark-green-color);
Expand All @@ -48,6 +48,26 @@
color: var(--ams-avatar-green-color);
}

.ams-avatar--grey-1 {
background-color: var(--ams-avatar-grey-1-background-color);
color: var(--ams-avatar-grey-1-color);
}

.ams-avatar--grey-2 {
background-color: var(--ams-avatar-grey-2-background-color);
color: var(--ams-avatar-grey-2-color);
}

.ams-avatar--grey-3 {
background-color: var(--ams-avatar-grey-3-background-color);
color: var(--ams-avatar-grey-3-color);
}

.ams-avatar--light-blue {
background-color: var(--ams-avatar-light-blue-background-color);
color: var(--ams-avatar-light-blue-color);
}

.ams-avatar--magenta {
background-color: var(--ams-avatar-magenta-background-color);
color: var(--ams-avatar-magenta-color);
Expand All @@ -68,6 +88,11 @@
color: var(--ams-avatar-red-color);
}

.ams-avatar--white {
background-color: var(--ams-avatar-white-background-color);
color: var(--ams-avatar-white-color);
}

.ams-avatar--yellow {
background-color: var(--ams-avatar-yellow-background-color);
color: var(--ams-avatar-yellow-color);
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Avatar/Avatar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('Avatar', () => {

const component = container.querySelector(':only-child')

expect(component).toHaveClass('ams-avatar--dark-blue')
expect(component).toHaveClass('ams-avatar--blue')
})

avatarColors.map((color) =>
Expand Down
12 changes: 7 additions & 5 deletions packages/react/src/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ import { Image } from '../Image'
import { VisuallyHidden } from '../VisuallyHidden'

export const avatarColors = [
'black',
'blue',
'dark-blue',
'dark-green',
'green',
'grey-1',
'grey-2',
'grey-3',
'light-blue',
'magenta',
'orange',
'purple',
'red',
'white',
'yellow',
] as const

Expand Down Expand Up @@ -52,10 +57,7 @@ export type AvatarProps = {
} & HTMLAttributes<HTMLSpanElement>

export const Avatar = forwardRef(
(
{ label, imageSrc, className, color = 'dark-blue', ...restProps }: AvatarProps,
ref: ForwardedRef<HTMLSpanElement>,
) => {
({ label, imageSrc, className, color = 'blue', ...restProps }: AvatarProps, ref: ForwardedRef<HTMLSpanElement>) => {
const initials = label.slice(0, 2).toUpperCase()

const a11yLabel = initials.length === 0 ? 'Gebruiker' : `Initialen gebruiker: ${initials}`
Expand Down
28 changes: 24 additions & 4 deletions proprietary/tokens/src/components/ams/avatar.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"line-height": { "value": "{ams.text.level.6.line-height}" },
"padding-block": { "value": "0.25rem" },
"padding-inline": { "value": "0.25rem" },
"blue": {
"background-color": { "value": "{ams.color.blue}" },
"color": { "value": "{ams.color.primary-black}" }
"black": {
"background-color": { "value": "{ams.color.primary-black}" },
"color": { "value": "{ams.color.primary-white}" }
},
"dark-blue": {
"blue": {
"background-color": { "value": "{ams.color.primary-blue}" },
"color": { "value": "{ams.color.primary-white}" }
},
Expand All @@ -24,6 +24,22 @@
"background-color": { "value": "{ams.color.green}" },
"color": { "value": "{ams.color.primary-black}" }
},
"grey-1": {
"background-color": { "value": "{ams.color.neutral-grey1}" },
"color": { "value": "{ams.color.primary-black}" }
},
"grey-2": {
"background-color": { "value": "{ams.color.neutral-grey2}" },
"color": { "value": "{ams.color.primary-black}" }
},
"grey-3": {
"background-color": { "value": "{ams.color.neutral-grey3}" },
"color": { "value": "{ams.color.primary-white}" }
},
"light-blue": {
"background-color": { "value": "{ams.color.blue}" },
"color": { "value": "{ams.color.primary-black}" }
},
"magenta": {
"background-color": { "value": "{ams.color.magenta}" },
"color": { "value": "{ams.color.primary-white}" }
Expand All @@ -40,6 +56,10 @@
"background-color": { "value": "{ams.color.primary-red}" },
"color": { "value": "{ams.color.primary-white}" }
},
"white": {
"background-color": { "value": "{ams.color.primary-white}" },
"color": { "value": "{ams.color.primary-black}" }
},
"yellow": {
"background-color": { "value": "{ams.color.yellow}" },
"color": { "value": "{ams.color.primary-black}" }
Expand Down
Loading