Skip to content

Commit

Permalink
fix(Alert.Description): moved conditional classes to defaultClass so …
Browse files Browse the repository at this point in the history
…they can be overridden
  • Loading branch information
Craig Howell committed Oct 2, 2022
1 parent 6f8d4cf commit e5b321c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/lib/components/alert/Description.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
const { type }: { type: 'info' | 'warn' | 'success' | 'error' } = getContext(ALERT_CONTEXT_ID);
const defaultClass = 'mt-2 text-sm transition-all duration-150';
let defaultClass = 'mt-2 text-sm transition-all duration-150';
if (type === 'info') {
defaultClass += ' text-info-secondary-content dark:text-dark-info-secondary-content';
} else if (type === 'warn') {
defaultClass += ' text-warn-secondary-content dark:text-dark-warn-secondary-content';
} else if (type === 'success') {
defaultClass += ' text-success-secondary-content dark:text-dark-success-secondary-content';
} else if (type === 'error') {
defaultClass += ' text-error-secondary-content dark:text-dark-error-secondary-content=';
}
const finalClass = twMerge(defaultClass, $$props.class);
</script>

<div
class={finalClass}
class:text-info-secondary-content={type === 'info'}
class:text-warn-secondary-content={type === 'warn'}
class:text-success-secondary-content={type === 'success'}
class:text-error-secondary-content={type === 'error'}
class:dark:text-dark-info-secondary-content={type === 'info'}
class:dark:text-dark-warn-secondary-content={type === 'warn'}
class:dark:text-dark-success-secondary-content={type === 'success'}
class:dark:text-dark-error-secondary-content={type === 'error'}
style={$$props.style}
>
<div class={finalClass} style={$$props.style}>
<slot />
</div>

0 comments on commit e5b321c

Please sign in to comment.