Skip to content

Commit

Permalink
fix(Alert): added class identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
N00nDay committed Oct 2, 2023
1 parent 7d5e57b commit 32a61e0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
40 changes: 19 additions & 21 deletions src/lib/components/alert/Alert.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
const currentType = writable(type);
$: currentType.set(type);
const defaultClass = 'rounded-md p-4';
const defaultLeadingClass = 'flex-grow flex flex-col w-6 flex items-center';
const defaultClass = 'rounded-md p-4 flex relative stwui-alert';
const defaultLeadingClass = 'flex-grow flex flex-col w-6 flex items-center stwui-alert-leading';
$: finalClass = twMerge(
defaultClass,
Expand Down Expand Up @@ -47,24 +47,22 @@
use:forwardEvents
{...exclude($$props, ['use', 'class'])}
>
<div class="flex relative">
{#if $$slots.leading}
<div class={finalLeadingClass}>
<slot name="leading" />
</div>
{/if}
{#if $$slots.leading}
<div class={finalLeadingClass}>
<slot name="leading" />
</div>
{/if}

{#if $$slots.title || $$slots.description}
<div
class="flex items-start flex-col w-full"
class:ml-3={$$slots.leading}
class:justify-start={$$slots.description}
class:justify-center={!$$slots.description}
>
<slot name="title" />
<slot name="description" />
</div>
{/if}
<slot name="extra" />
</div>
{#if $$slots.title || $$slots.description}
<div
class="flex items-start flex-col w-full stwui-alert-title-description-wrapper"
class:ml-3={$$slots.leading}
class:justify-start={$$slots.description}
class:justify-center={!$$slots.description}
>
<slot name="title" />
<slot name="description" />
</div>
{/if}
<slot name="extra" />
</div>
2 changes: 1 addition & 1 deletion src/lib/components/alert/Description.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const type: Writable<'info' | 'warn' | 'success' | 'error'> = getContext('alert-type');
const defaultClass = 'text-sm';
const defaultClass = 'text-sm stwui-alert-description';
const infoClass = 'text-info-secondary-content';
const warnClass = 'text-warn-secondary-content';
const successClass = 'text-success-secondary-content';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/alert/Extra.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
const type: Writable<'info' | 'warn' | 'success' | 'error'> = getContext('alert-type');
const alertDescription: boolean = getContext('alert-description');
const defaultClass = 'flex-shrink-0 flex items-center justify-center';
const defaultClass = 'flex-shrink-0 flex items-center justify-center stwui-alert-extra';
const infoClass = 'text-info-icon ';
const warnClass = 'text-warn-icon';
const successClass = 'text-success-icon';
Expand All @@ -24,7 +24,7 @@
$type === 'success' ? successClass : false,
$type === 'error' ? errorClass : false,
alertDescription ? 'absolute -top-2 -right-2' : false,
alertDescription ? 'absolute top-2.5 right-2.5' : false,
$$props.class
);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/alert/Title.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
const type: Writable<'info' | 'warn' | 'success' | 'error'> = getContext('alert-type');
const defaultClass = 'mb-0 flex flex-row items-start justify-between w-full relative';
const defaultClass =
'mb-0 flex flex-row items-start justify-between w-full relative stwui-alert-title';
const infoClass = 'text-info-content';
const warnClass = 'text-warn-content';
const successClass = 'text-success-content';
Expand Down

0 comments on commit 32a61e0

Please sign in to comment.