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

Support mergable classes #1849

Merged
merged 9 commits into from
Feb 15, 2024
6 changes: 5 additions & 1 deletion src/lib/holocene/accordion.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { HTMLAttributes } from 'svelte/elements';
import { noop } from 'svelte/internal';

import { twMerge as merge } from 'tailwind-merge';
import { v4 } from 'uuid';

import Badge from '$lib/holocene/badge.svelte';
Expand Down Expand Up @@ -45,7 +46,10 @@
</script>

<div
class="surface-primary flex w-full cursor-default flex-col rounded-xl border-2 p-4 text-primary {className}"
class={merge(
'surface-primary flex w-full cursor-default flex-col rounded-xl border-2 p-4 text-primary',
className,
)}
{...$$restProps}
>
<button
Expand Down
4 changes: 3 additions & 1 deletion src/lib/holocene/alert.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';

import { twMerge as merge } from 'tailwind-merge';

import Icon from '$lib/holocene/icon/icon.svelte';

import type { IconName } from './icon/paths';
Expand Down Expand Up @@ -45,7 +47,7 @@
</script>

<div
class="alert flex {intent} {className}"
class={merge('alert flex', intent, className)}
class:bold
class:hidden
{role}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/holocene/combobox/combobox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { writable } from 'svelte/store';

import { createEventDispatcher } from 'svelte';
import { twMerge as merge } from 'tailwind-merge';

import ComboboxOption from '$lib/holocene/combobox/combobox-option.svelte';
import MenuContainer from '$lib/holocene/menu/menu-container.svelte';
Expand Down Expand Up @@ -262,7 +263,7 @@
type="text"
value={displayValue}
class:disabled
class="combobox-input {className}"
class={merge('combobox-input', className)}
role="combobox"
autocomplete="off"
autocapitalize="off"
Expand Down
4 changes: 3 additions & 1 deletion src/lib/holocene/copyable/button.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import type { HTMLButtonAttributes } from 'svelte/elements';

import { twMerge as merge } from 'tailwind-merge';

import Icon from '$lib/holocene/icon/icon.svelte';

interface $$Props extends HTMLButtonAttributes {
Expand All @@ -18,7 +20,7 @@
export { className as class };
</script>

<button class="copy-button {className}" on:click {...$$restProps}>
<button class={merge('copy-button', className)} on:click {...$$restProps}>
<Icon
title={copied ? copySuccessIconTitle : copyIconTitle}
name={copied ? 'checkmark' : 'copy'}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/holocene/filter-or-copy-buttons.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import { noop } from 'svelte/internal';

import { twMerge as merge } from 'tailwind-merge';

import Icon from '$lib/holocene/icon/icon.svelte';
import { copyToClipboard } from '$lib/utilities/copy-to-clipboard';

Expand All @@ -22,7 +24,7 @@

{#if show}
<div
class="copy-or-filter {className}"
class={merge('copy-or-filter', className)}
on:click|preventDefault|stopPropagation={noop}
on:keyup|preventDefault|stopPropagation={noop}
>
Expand Down
4 changes: 3 additions & 1 deletion src/lib/holocene/icon-button.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import type { HTMLButtonAttributes } from 'svelte/elements';

import { twMerge as merge } from 'tailwind-merge';

import Icon from '$lib/holocene/icon/icon.svelte';
import type { IconName } from '$lib/holocene/icon/paths';

Expand All @@ -18,7 +20,7 @@

<button
type="button"
class="icon-button {className}"
class={merge('icon-button', className)}
on:click
aria-label={label}
{...$$restProps}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/holocene/input/input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { HTMLInputAttributes } from 'svelte/elements';

import { createEventDispatcher } from 'svelte';
import { twMerge as merge } from 'tailwind-merge';

import Icon from '$lib/holocene/icon/icon.svelte';
import type { IconName } from '$lib/holocene/icon/paths';
Expand Down Expand Up @@ -85,7 +86,7 @@
$: disabled = disabled || copyable;
</script>

<div class="flex flex-col gap-1 {className}">
<div class={merge('flex flex-col gap-1', className)}>
<label class={theme} class:required class:sr-only={labelHidden} for={id}
>{label}</label
>
Expand Down
4 changes: 3 additions & 1 deletion src/lib/holocene/link.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import type { HTMLAnchorAttributes } from 'svelte/elements';

import { twMerge as merge } from 'tailwind-merge';

import { goto } from '$app/navigation';

import type { IconName } from '$lib/holocene/icon/paths';
Expand Down Expand Up @@ -38,7 +40,7 @@
{href}
target={newTab ? '_blank' : null}
rel={newTab ? 'noreferrer' : null}
class="link {icon ? 'inline-flex' : 'inline'} {className}"
class={merge('link', icon ? 'inline-flex' : 'inline', className)}
class:active
on:click={onLinkClick}
tabindex={href ? null : 0}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/holocene/menu/menu-button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import type { HTMLButtonAttributes } from 'svelte/elements';

import { createEventDispatcher, getContext } from 'svelte';
import { twMerge as merge } from 'tailwind-merge';

import Badge from '$lib/holocene/badge.svelte';
import Icon from '$lib/holocene/icon/icon.svelte';
Expand Down Expand Up @@ -105,7 +106,7 @@
aria-controls={controls}
aria-expanded={$open}
aria-label={label}
class="menu-button {variant} {className}"
class={merge('menu-button', variant, className)}
class:unroundLeft
class:unroundRight
class:active
Expand Down
3 changes: 2 additions & 1 deletion src/lib/holocene/menu/menu-container.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { writable, type Writable } from 'svelte/store';

import { createEventDispatcher, setContext } from 'svelte';
import { twMerge as merge } from 'tailwind-merge';

import { clickOutside } from '$lib/holocene/outside-click';

Expand Down Expand Up @@ -44,7 +45,7 @@
<div
use:clickOutside
on:click-outside={closeMenu}
class="relative {className}"
class={merge('relative', className)}
{...$$restProps}
>
<slot {open} />
Expand Down
5 changes: 3 additions & 2 deletions src/lib/holocene/menu/menu-item.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import type { HTMLLiAttributes } from 'svelte/elements';

import { createEventDispatcher, getContext } from 'svelte';
import { twMerge as merge } from 'tailwind-merge';

import Icon from '$lib/holocene/icon/icon.svelte';

Expand Down Expand Up @@ -107,7 +108,7 @@
<a
{href}
role="menuitem"
class="menu-item {theme} {className}"
class={merge('menu-item', theme, className)}
class:disabled
aria-hidden={disabled ? 'true' : 'false'}
aria-disabled={disabled}
Expand All @@ -120,7 +121,7 @@
{:else}
<li
role="menuitem"
class="menu-item {theme} {className}"
class={merge('menu-item', theme, className)}
class:destructive
class:disabled
aria-hidden={disabled ? 'true' : 'false'}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/holocene/menu/menu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { fly } from 'svelte/transition';

import { getContext } from 'svelte';
import { twMerge as merge } from 'tailwind-merge';

import { getFocusableElements } from '$lib/utilities/focus-trap';

Expand Down Expand Up @@ -44,7 +45,7 @@
<ul
in:fly={{ duration: 100 }}
role="menu"
class="menu {position} {theme} {className}"
class={merge('menu', position, theme, className)}
class:hidden={!$open}
aria-labelledby={id}
tabindex={-1}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/holocene/modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { HTMLAttributes } from 'svelte/elements';

import { type ComponentProps, createEventDispatcher } from 'svelte';
import { twMerge as merge } from 'tailwind-merge';

import Button from '$lib/holocene/button.svelte';
import { focusTrap } from '$lib/utilities/focus-trap';
Expand Down Expand Up @@ -81,7 +82,7 @@
{id}
on:close={handleCancel}
bind:this={modalElement}
class="body {className}"
class={merge('body', className)}
class:large
class:hightlightNav
aria-modal="true"
Expand Down
3 changes: 2 additions & 1 deletion src/lib/holocene/radio-input/radio-group.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import type { Writable } from 'svelte/store';

import { setContext } from 'svelte';
import { twMerge as merge } from 'tailwind-merge';

import type { RadioGroupContext, RadioGroupProps } from './types';

Expand All @@ -25,7 +26,7 @@
});
</script>

<div class="flex flex-col gap-2 {className}" {...$$restProps}>
<div class={merge('flex flex-col gap-2', className)} {...$$restProps}>
{#if description}
<p class="font-secondary text-sm font-medium">{description}</p>
{/if}
Expand Down
7 changes: 6 additions & 1 deletion src/lib/holocene/select/simple-select.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import type { HTMLSelectAttributes } from 'svelte/elements';

import { twMerge as merge } from 'tailwind-merge';

import type { SelectOptionValue } from '$lib/types/global';

import Option from './simple-option.svelte';
Expand Down Expand Up @@ -30,7 +32,10 @@
<div>
<label class="sr-only" for={id}>{label}</label>
<select
class="inline h-10 w-full rounded-lg border-2 px-2 text-base {className}"
class={merge(
'inline h-10 w-full rounded-lg border-2 px-2 text-base',
className,
)}
class:dark
class:remove={arrow}
{name}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/holocene/tab/tab-list.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';

import { twMerge as merge } from 'tailwind-merge';

interface $$Props extends HTMLAttributes<HTMLDivElement> {
label: string;
class?: string;
Expand All @@ -12,7 +14,7 @@
</script>

<div
class="tab-list {className}"
class={merge('tab-list', className)}
role="tablist"
aria-label={label}
{...$$restProps}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/holocene/table/table.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import type { HTMLTableAttributes } from 'svelte/elements';

import { twMerge as merge } from 'tailwind-merge';

import ProgressBar from '$lib/holocene/progress-bar.svelte';

interface $$Props extends HTMLTableAttributes {
Expand All @@ -16,7 +18,7 @@
export let updating = false;
</script>

<table class="{variant} {className}" {...$$restProps}>
<table class={merge(variant, className)} {...$$restProps}>
<slot name="caption" />
<thead>
<slot name="headers" />
Expand Down
4 changes: 3 additions & 1 deletion src/lib/holocene/toggle-button/toggle-button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
HTMLButtonAttributes,
} from 'svelte/elements';

import { twMerge as merge } from 'tailwind-merge';

import { page } from '$app/stores';

import Icon from '$lib/holocene/icon/icon.svelte';
Expand Down Expand Up @@ -42,7 +44,7 @@

<svelte:element
this={href ? 'a' : 'button'}
class="toggle-button {className}"
class={merge('toggle-button', className)}
class:group
class:active={href ? $page.url.pathname.includes(base) : active}
href={href ? href + $page.url.search : null}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/holocene/tooltip.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts">
import { twMerge as merge } from 'tailwind-merge';

import Copyable from '$lib/holocene/copyable/index.svelte';
import Icon from '$lib/holocene/icon/icon.svelte';
import type { IconName } from '$lib/holocene/icon/paths';
Expand Down Expand Up @@ -83,7 +85,7 @@
{#if hide}
<slot />
{:else}
<div class="wrapper relative inline-block {className}">
<div class={merge('wrapper relative inline-block', className)}>
<slot />
<div
class="tooltip"
Expand Down
Loading