mirror of
https://github.com/tabler/tabler.git
synced 2026-08-29 13:21:29 +04:00
Narrow component prop types, remove unused props and dead code (#2838)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
+8
-21
@@ -1,34 +1,33 @@
|
||||
---
|
||||
import Icon from './Icon.astro'
|
||||
import ButtonList from './ButtonList.astro'
|
||||
|
||||
/** alert-{type} / btn-{type} — matches defaultIcons below */
|
||||
type AlertType = 'success' | 'warning' | 'danger' | 'info'
|
||||
|
||||
interface Props {
|
||||
type?: string
|
||||
icon?: string
|
||||
type?: AlertType
|
||||
important?: boolean
|
||||
minor?: boolean
|
||||
showClose?: boolean
|
||||
avatar?: boolean
|
||||
class?: string
|
||||
title?: string
|
||||
description?: string
|
||||
list?: string[]
|
||||
action?: string
|
||||
link?: string
|
||||
buttons?: boolean
|
||||
}
|
||||
|
||||
const { type = 'success', icon: iconProp, important, minor, showClose, avatar, class: className, title = 'This is a custom alert box!', description, list, action, link, buttons } = Astro.props
|
||||
const { type = 'success', important, minor, showClose, class: className, title = 'This is a custom alert box!', description, list, action, link } = Astro.props
|
||||
|
||||
const defaultIcons: Record<string, string> = {
|
||||
const defaultIcons: Record<AlertType, string> = {
|
||||
success: 'check',
|
||||
warning: 'alert-triangle',
|
||||
danger: 'alert-circle',
|
||||
info: 'info-circle',
|
||||
}
|
||||
const icon = iconProp ?? defaultIcons[type]
|
||||
const icon = defaultIcons[type]
|
||||
|
||||
const classes = ['alert', important ? 'alert-important' : minor ? 'alert-minor' : undefined, `alert-${type}`, showClose && 'alert-dismissible', avatar && 'alert-avatar', className]
|
||||
const classes = ['alert', important ? 'alert-important' : minor ? 'alert-minor' : undefined, `alert-${type}`, showClose && 'alert-dismissible', className]
|
||||
---
|
||||
|
||||
<div class:list={classes} role="alert">
|
||||
@@ -65,17 +64,5 @@ const classes = ['alert', important ? 'alert-important' : minor ? 'alert-minor'
|
||||
</Fragment>
|
||||
)
|
||||
}
|
||||
{
|
||||
buttons && (
|
||||
<ButtonList>
|
||||
<a href="#" class={`btn btn-${type}`}>
|
||||
Okay
|
||||
</a>
|
||||
<a href="#" class="btn">
|
||||
Cancel
|
||||
</a>
|
||||
</ButtonList>
|
||||
)
|
||||
}
|
||||
{showClose && <a class="btn-close" data-bs-dismiss="alert" aria-label="close" />}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user