✨ Rework buttons classes and variants
Add a conditional class and list props as BEM class modifiers
This commit is contained in:
@@ -1,15 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import SplitText from '$components/SplitText.svelte'
|
import SplitText from '$components/SplitText.svelte'
|
||||||
|
|
||||||
export let text: string
|
|
||||||
export let tag: string = 'a'
|
export let tag: string = 'a'
|
||||||
export let effect: string = 'link-3d'
|
export let text: string
|
||||||
export let url: string = undefined
|
export let url: string = undefined
|
||||||
|
export let color: string = undefined
|
||||||
|
export let size: string = undefined
|
||||||
|
export let effect: string = 'link-3d'
|
||||||
export let disabled: boolean = undefined
|
export let disabled: boolean = undefined
|
||||||
|
|
||||||
|
const className = 'button'
|
||||||
const classes = [
|
const classes = [
|
||||||
'button',
|
className,
|
||||||
effect ?? null,
|
effect ? effect : undefined,
|
||||||
|
...[color, size].map(variant => variant && `${className}--${variant}`),
|
||||||
$$props.class
|
$$props.class
|
||||||
].join(' ').trim()
|
].join(' ').trim()
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,7 +1,26 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
export let color: string = undefined
|
||||||
|
export let size: string = undefined
|
||||||
|
export let type: string = undefined
|
||||||
|
export let form: string = undefined
|
||||||
|
export let clone: boolean = false
|
||||||
|
|
||||||
|
const className = 'button-circle'
|
||||||
|
const classes = [
|
||||||
|
className,
|
||||||
|
...[color, size].map(variant => variant && `${className}--${variant}`),
|
||||||
|
$$props.class
|
||||||
|
].join(' ').trim()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button class="button-circle" on:click>
|
<button {type} {form} class={classes} on:click>
|
||||||
|
{#if clone}
|
||||||
|
{#each Array(2) as _}
|
||||||
|
<span class="clone">
|
||||||
<slot />
|
<slot />
|
||||||
|
</span>
|
||||||
|
{/each}
|
||||||
|
{:else}
|
||||||
|
<slot />
|
||||||
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import { getContext } from 'svelte'
|
import { getContext } from 'svelte'
|
||||||
// Components
|
// Components
|
||||||
import IconArrow from '$components/atoms/IconArrow.svelte'
|
import IconArrow from '$components/atoms/IconArrow.svelte'
|
||||||
|
import ButtonCircle from '$components/atoms/ButtonCircle.svelte'
|
||||||
|
|
||||||
export let past: boolean = false
|
export let past: boolean = false
|
||||||
|
|
||||||
@@ -20,9 +21,13 @@
|
|||||||
on:focus={toggleFocus}
|
on:focus={toggleFocus}
|
||||||
on:blur={toggleFocus}
|
on:blur={toggleFocus}
|
||||||
>
|
>
|
||||||
<button type="submit" form="sib-form">
|
<ButtonCircle
|
||||||
|
type="submit" form="sib-form"
|
||||||
|
color="pink" size="small"
|
||||||
|
clone={true}
|
||||||
|
>
|
||||||
<IconArrow color="white" />
|
<IconArrow color="white" />
|
||||||
</button>
|
</ButtonCircle>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="text" name="email_address_check" value="" style="display: none;">
|
<input type="text" name="email_address_check" value="" style="display: none;">
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
{#each continents as { name, slug }}
|
{#each continents as { name, slug }}
|
||||||
<li class:is-disabled={currentContinent && currentContinent !== slug}>
|
<li class:is-disabled={currentContinent && currentContinent !== slug}>
|
||||||
<Button
|
<Button
|
||||||
tag="button" text={name} class="button--small"
|
tag="button" text={name} size="small"
|
||||||
on:click={() => filterLocation(slug)}
|
on:click={() => filterLocation(slug)}
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -29,11 +29,7 @@
|
|||||||
<h3 class="title-medium">{shop.module_title}</h3>
|
<h3 class="title-medium">{shop.module_title}</h3>
|
||||||
<p class="text-small">{shop.module_text}</p>
|
<p class="text-small">{shop.module_text}</p>
|
||||||
{#if shop.enabled}
|
{#if shop.enabled}
|
||||||
<Button
|
<Button url="/shop" text="Shop" color="pink" />
|
||||||
url="/shop"
|
|
||||||
text="Shop"
|
|
||||||
class="button--pink"
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
<p class="detail">
|
<p class="detail">
|
||||||
Posters available for {locationsWithPoster.join(', ').replace(/,(?!.*,)/gmi, ' and')}.
|
Posters available for {locationsWithPoster.join(', ').replace(/,(?!.*,)/gmi, ' and')}.
|
||||||
|
|||||||
@@ -60,15 +60,10 @@ import ButtonCircle from '$components/atoms/ButtonCircle.svelte'
|
|||||||
|
|
||||||
<div class="viewer-photo__controls">
|
<div class="viewer-photo__controls">
|
||||||
<ButtonCircle on:click={goToPrevious}>
|
<ButtonCircle on:click={goToPrevious}>
|
||||||
<IconArrow
|
<IconArrow color="pink" flip={true} />
|
||||||
color="pink"
|
|
||||||
flip={true}
|
|
||||||
/>
|
|
||||||
</ButtonCircle>
|
</ButtonCircle>
|
||||||
<ButtonCircle on:click={goToPrevious}>
|
<ButtonCircle on:click={goToPrevious}>
|
||||||
<IconArrow
|
<IconArrow color="pink" />
|
||||||
color="pink"
|
|
||||||
/>
|
|
||||||
</ButtonCircle>
|
</ButtonCircle>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
<Button url="/locations" text="Change location" class="shadow-small">
|
<Button url="/locations" text="Change location" class="shadow-small">
|
||||||
<IconEarth />
|
<IconEarth />
|
||||||
</Button>
|
</Button>
|
||||||
<Button url="/shop" text="Buy the poster" class="button--pink shadow-small">
|
<Button url="/shop" text="Buy the poster" color="pink" class="shadow-small">
|
||||||
<!-- <IconEarth /> -->
|
<!-- <IconEarth /> -->
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -298,8 +298,8 @@
|
|||||||
<Button
|
<Button
|
||||||
tag="button"
|
tag="button"
|
||||||
text={!ended ? 'See more photos' : "You've seen it all!"}
|
text={!ended ? 'See more photos' : "You've seen it all!"}
|
||||||
|
size="large" color="beige"
|
||||||
on:click={loadMorePhotos}
|
on:click={loadMorePhotos}
|
||||||
class="button--large button--beige"
|
|
||||||
disabled={ended}
|
disabled={ended}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -37,19 +37,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
button {
|
button {
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 16px;
|
right: 16px;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
margin-left: 32px;
|
margin-left: 32px;
|
||||||
background-color: $color-secondary;
|
|
||||||
height: 32px;
|
|
||||||
width: 32px;
|
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
border-radius: 100vh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// States
|
// States
|
||||||
|
|||||||
Reference in New Issue
Block a user