Skip to content

Commit

Permalink
refactor: improve code consistency and formatting in banner component
Browse files Browse the repository at this point in the history
- Added missing semicolons for better code style consistency.
- Updated the `BannerOptions` interface to include semicolons for clarity.
- Ensured consistent formatting in the `COLORS` and `ICONS` objects.
- Improved readability by adding semicolons in destructuring assignments.
  • Loading branch information
spences10 committed Jan 4, 2025
1 parent d5c9fc5 commit d3103e6
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/lib/components/banner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@
LightBulb,
Megaphone,
WarningTriangle,
} from '$lib/icons'
} from '$lib/icons';
interface Props {
options?: BannerOptions
options?: BannerOptions;
}
interface BannerOptions {
type: 'info' | 'tip' | 'warning' | 'announcement'
message: string
type: 'info' | 'tip' | 'warning' | 'announcement';
message: string;
}
let {
options = {
type: 'info',
message: '',
},
}: Props = $props()
}: Props = $props();
const ICONS = {
info: InformationCircle,
tip: LightBulb,
warning: WarningTriangle,
announcement: Megaphone,
}
};
const COLORS = {
info: { bg: 'bg-info', text: 'text-info-content' },
tip: { bg: 'bg-info', text: 'text-info-content' },
warning: { bg: 'bg-warning', text: 'text-warning-content' },
announcement: { bg: 'bg-success', text: 'text-success-content' },
promotion: { bg: 'bg-success', text: 'text-success-content' },
}
info: { bg: 'bg-info', text: '!text-info-content' },
tip: { bg: 'bg-info', text: '!text-info-content' },
warning: { bg: 'bg-warning', text: '!text-warning-content' },
announcement: { bg: 'bg-success', text: '!text-success-content' },
promotion: { bg: 'bg-success', text: '!text-success-content' },
};
const { bg, text } = COLORS[options.type] ?? COLORS['info']
const banner_classes = `${bg} ${text} px-12 py-4`
const Icon = ICONS[options.type] ?? InformationCircle
const { bg, text } = COLORS[options.type] ?? COLORS['info'];
const banner_classes = `${bg} ${text} px-12 py-4`;
const Icon = ICONS[options.type] ?? InformationCircle;
</script>

<div
Expand Down

0 comments on commit d3103e6

Please sign in to comment.