2022-09-29 10:31:01 +00:00
|
|
|
import clsx from 'clsx'
|
2022-09-09 11:53:35 +00:00
|
|
|
import { mergeProps, Show } from 'solid-js'
|
2022-09-29 10:31:01 +00:00
|
|
|
import type { JSX } from 'solid-js'
|
2022-09-09 11:53:35 +00:00
|
|
|
import './Icon.css'
|
|
|
|
|
2022-09-29 10:31:01 +00:00
|
|
|
type IconProps = {
|
2022-09-29 19:37:49 +00:00
|
|
|
class?: string
|
2022-09-29 10:31:01 +00:00
|
|
|
iconClassName?: string
|
|
|
|
style?: string | JSX.CSSProperties
|
|
|
|
title?: string
|
|
|
|
name?: string
|
|
|
|
counter?: number
|
|
|
|
}
|
|
|
|
|
|
|
|
export const Icon = (passedProps: IconProps) => {
|
|
|
|
const props = mergeProps({ title: '', counter: 0 }, passedProps)
|
2022-09-09 11:53:35 +00:00
|
|
|
|
|
|
|
return (
|
2022-09-29 19:37:49 +00:00
|
|
|
<div class={clsx('icon', props.class)} style={props.style}>
|
2022-09-29 10:31:01 +00:00
|
|
|
<img src={`/icons/${props.name}.svg`} alt={props.title ?? props.name} class={props.iconClassName} />
|
2022-09-09 11:53:35 +00:00
|
|
|
<Show when={props.counter}>
|
2022-09-29 10:31:01 +00:00
|
|
|
<div class="notifications-counter">{props.counter}</div>
|
2022-09-09 11:53:35 +00:00
|
|
|
</Show>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|