Skip to content
Closed
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
5 changes: 5 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://use.typekit.net/fha6pnq.css">

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap" rel="stylesheet">

<title>Samfundet</title>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/BackButton/BackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function BackButton({ url }: BackButtonProps) {
};

return (
<Button theme="outlined" rounded={true} onClick={goBack}>
<Button theme="secondary" rounded={true} onClick={goBack}>
{t(KEY.common_go_back)}
</Button>
);
Expand Down
232 changes: 107 additions & 125 deletions frontend/src/Components/Button/Button.module.scss
Original file line number Diff line number Diff line change
@@ -1,185 +1,167 @@
/* stylelint-disable declaration-no-important */
@use 'src/constants' as *;

@use 'src/mixins' as *;

@use 'src/styles/variables' as v;

@use 'src/styles/colors' as c;

@use 'sass:color';

.button {
@include flex-row;
gap: 0.5rem;
border: none;
gap: 0.25rem;
cursor: pointer;
border-radius: 0.25em;
transition: 0.15s;
box-shadow: 1px 1px 10px 3px rgba(0, 0, 0, 0.05);
border-radius: v.$border-radius-md;
justify-content: center;
font-size: v.$font-size;
transition: background-color 0.04s ease-in-out;
font-weight: v.$font-weight-medium;
border: 1px solid transparent;

// Remove underline when button is a link
&,
&:hover {
text-decoration: none;
}

&:disabled {
opacity: 0.5;
background-color: $grey-3;
color: $grey-1;
cursor: not-allowed;
}

&:hover:not([disabled]) {
filter: brightness(120%);
transition: 0.15s;
box-shadow: 1px 2px 15px 3px rgba(0, 0, 0, 0.05);
}
}

.button_basic {
background-color: white;
color: black;
.button:disabled,
.button:disabled:hover {
background-color: c.$gray-300;
color: c.$gray-50;
cursor: not-allowed;
}

.button_selected {
background-color: white;
color: black;
box-shadow: inset 0 0 1.5px 2px rgba(0, 0, 0, 0.15);
cursor: default;
//
// Shape
//

// Override hover effects for selected buttons
&:hover:not([disabled]) {
filter: none;
box-shadow: inset 0 0 1.5px 2px rgba(0, 0, 0, 0.15);
}
.display_basic {
padding: 8px 14px;
}

.button_samf {
background-color: $red-samf;
color: white;
.display_pill {
padding: 0.3em 0.4em;
}

.button_uka {
background-color: $blue-uka;
color: white;
.display_block {
padding: 10px 25px;
width: 100%;
}

.button_isfit {
background-color: $blue-isfit;
color: white;
.rounded {
border-radius: 10000px;
}

.button_lyche {
background-color: $sulten-orange;
color: white;
}
//
// Themes
//

.button_success {
background-color: $green;
color: white;
}
.button_primary {
background-color: c.$samf-red-700;
color: c.$red-50;

.button_blue {
background-color: $blue;
color: white;
&:hover {
background-color: color.adjust(c.$samf-red-700, $lightness: -5%);
}
}

.button_secondary {
border: none;
padding: 10px 25px;
background-color: $grey-3;
color: white;
}
background-color: c.$white-50;
color: c.$gray-700;
border-color: c.$gray-200;

.button_outlined {
background-color: inherit;
border: 1px solid $grey-1;
transition: 0.15s;
&:hover {
background-color: c.$gray-100;
}

&:hover:not([disabled]) {
border-color: $red-samf;
color: $red-samf;
transition: 0.15s;
@include theme-dark {
background-color: c.$gray-900;
color: c.$gray-100;
border-color: c.$gray-800;

&:hover {
background-color: color.adjust(c.$gray-900, $lightness: 4%);
}
}
}

.button_black {
background-color: $black;
color: white;
transition: 0.15s;
.button_success {
background-color: c.$green-700;
color: c.$green-50;

&:hover:not([disabled]) {
background-color: $grey-1;
transition: 0.15s;
&:hover {
background-color: color.adjust(c.$green-700, $lightness: -8%);
}
}

.button_white {
background-color: $white;
color: black;
transition: 0.15s;
.button_danger {
background-color: c.$gold-600;
color: c.$white-50;

&:hover:not([disabled]) {
filter: brightness(85%);
transition: 0.15s;
&:hover {
background-color: color.adjust(c.$gold-600, $lightness: -8%);
}
}

.button_yellow {
background-color: $yellow;
color: white;
}
.button_ghost {
background-color: transparent;
color: c.$gray-700;

&:hover {
background-color: c.$gray-100;
}

.button_green {
background-color: $green;
color: white;
transition: 0.15s;
@include theme-dark {
color: c.$white-50;

&:hover:not([disabled]) {
filter: brightness(110%);
transition: 0.15s;
&:hover {
background-color: c.$gray-800;
}
}
}

.display_basic {
padding: 10px 25px;
}
.button_uka {
background-color: c.$uka-blue;
color: c.$white-50;

.display_pill {
padding: 0.3em 0.4em;
&:hover {
background-color: color.adjust(c.$uka-blue, $lightness: -6%);
}
}

.display_block {
padding: 10px 25px;
width: 100%;
.button_isfit {
background-color: c.$isfit-primary;
color: c.$white-50;

&:hover {
background-color: color.adjust(c.$isfit-primary, $lightness: -5%);
}
}

.rounded {
border-radius: 10000px;
.button_black {
background-color: c.$gray-950;
color: c.$white-50;

&:hover {
background-color: c.$gray-800;
}
}

.pure {
background-color: transparent;
color: inherit;
border-width: 0;
font-family: inherit;
font-size: inherit;
font-style: inherit;
font-weight: inherit;
line-height: inherit;
.button_white {
background-color: c.$white-50;
color: c.$gray-800;

&:hover {
background-color: c.$gray-100;
}
}

.button_text {
background-color: transparent;
border-width: 0;
font-family: inherit;
font-size: inherit;
font-style: inherit;
font-weight: inherit;
line-height: inherit;
color: $red-samf;

&:hover:not([disabled]) {
filter: brightness(120%);
transition: 0.15s;
cursor: pointer;
text-decoration: underline;
.button_blue {
background-color: c.$blue-700;
color: c.$blue-50;

&:hover {
background-color: c.$blue-800;
}
}
4 changes: 2 additions & 2 deletions frontend/src/Components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const Basic: Story = {
render: (args) => <Button {...args}>Submit</Button>,
};

export const Samf: Story = {
args: { theme: 'samf' },
export const Primary: Story = {
args: { theme: 'primary' },
render: (args) => <Button {...args}>Submit</Button>,
};

Expand Down
8 changes: 3 additions & 5 deletions frontend/src/Components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type ButtonProps = {

export function Button({
name,
theme = 'basic',
theme = 'primary',
display = 'basic',
rounded = false,
type = 'button',
Expand All @@ -36,12 +36,10 @@ export function Button({
preventDefault = false,
...props
}: ButtonProps) {
const isPure = theme === 'pure' || theme === 'text';

const classNames = classnames(
!isPure && styles.button,
styles.button,
themeToStyleMap[theme],
!isPure && displayToStyleMap[display],
displayToStyleMap[display],
rounded && styles.rounded,
className,
);
Expand Down
21 changes: 9 additions & 12 deletions frontend/src/Components/Button/utils.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import classNames from 'classnames';
import styles from './Button.module.scss';

export const themeToStyleMap = {
basic: styles.button_basic,
selected: styles.button_selected,
pure: styles.pure,
text: styles.button_text,
samf: styles.button_samf,
lyche: styles.button_lyche,
primary: styles.button_primary,
secondary: styles.button_secondary,
success: styles.button_success,
outlined: classNames(styles.button_outlined, 'button_outlined'), // Must be globally available for theme-dark.
blue: styles.button_blue,
danger: styles.button_danger,
ghost: styles.button_ghost,

// Color-specific
black: styles.button_black,
white: styles.button_white,
green: styles.button_green,
blue: styles.button_blue,

// Special buttons
uka: styles.button_uka,
isfit: styles.button_isfit,
yellow: styles.button_yellow,
} as const;

/**
* basic: Normal button wrapping text.
* pill: Rounded button.
* block: Utilises full width.
* block: Utilizes full width.
*/
export const displayToStyleMap = {
basic: styles.display_basic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function BuyEventTicket({ event, ticketSaleState }: BuyButtonProps) {

return (
<>
<Button theme={'samf'} onClick={() => setShowModal(true)}>
<Button theme="primary" onClick={() => setShowModal(true)}>
<Icon icon="ph:ticket-bold" />
{buttonText}
</Button>
Expand Down
Loading