-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
120 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { type JSX, lazy } from 'solid-js'; | ||
|
||
import { | ||
type LabelModerationCause, | ||
type ModerationCause, | ||
type ModerationUI, | ||
CauseLabel, | ||
SeverityAlert, | ||
getLocalizedLabel, | ||
} from '~/api/moderation'; | ||
|
||
import { openModal } from '~/com/globals/modals'; | ||
|
||
import InfoOutlinedIcon from '../../icons/outline-info'; | ||
import ReportProblemOutlinedIcon from '../../icons/outline-report-problem'; | ||
|
||
const LabelDetailsDialog = lazy(() => import('../dialogs/LabelDetailsDialog')); | ||
|
||
export interface ModerationAlertsProps { | ||
ui: ModerationUI; | ||
class?: string; | ||
} | ||
|
||
const ModerationAlerts = (props: ModerationAlertsProps) => { | ||
return (() => { | ||
const ui = props.ui; | ||
const causes = ui.a.concat(ui.i).filter(isLabelCause); | ||
|
||
if (causes.length === 0) { | ||
return; | ||
} | ||
|
||
return ( | ||
<div class={props.class}> | ||
<div class="flex flex-wrap gap-2"> | ||
{ | ||
/* @once */ causes.map((cause) => { | ||
return ( | ||
<button | ||
onClick={() => { | ||
openModal(() => <LabelDetailsDialog cause={cause} />); | ||
}} | ||
class="flex items-center gap-2 rounded-md bg-secondary/30 px-2 text-de leading-6 text-primary/85 hover:bg-secondary/40 hover:text-primary" | ||
> | ||
{(() => { | ||
const Icon = cause.d.s === SeverityAlert ? ReportProblemOutlinedIcon : InfoOutlinedIcon; | ||
return <Icon />; | ||
})()} | ||
<span> | ||
{(() => { | ||
const localized = getLocalizedLabel(cause.d); | ||
return localized.n; | ||
})()} | ||
</span> | ||
</button> | ||
); | ||
}) | ||
} | ||
</div> | ||
</div> | ||
); | ||
}) as unknown as JSX.Element; | ||
}; | ||
|
||
export default ModerationAlerts; | ||
|
||
const isLabelCause = (c: ModerationCause): c is LabelModerationCause => { | ||
return c.t === CauseLabel; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters