feat(react): Replace the flag number with a colored badge
This commit is contained in:
parent
743314062d
commit
c66c9e0a93
1 changed files with 19 additions and 2 deletions
|
@ -242,7 +242,8 @@ export const HeaderMenuDraftViewUiPreferences = (props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const HeaderMenuDraftViewFlags = (props) => {
|
export const HeaderMenuDraftViewFlags = (props) => {
|
||||||
const count = Object.keys(flattenFlags(props.flags)).length
|
const flatFlags = flattenFlags(props.flags)
|
||||||
|
const count = Object.keys(flatFlags).length
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HeaderMenuDropdown
|
<HeaderMenuDropdown
|
||||||
|
@ -254,7 +255,12 @@ export const HeaderMenuDraftViewFlags = (props) => {
|
||||||
<HeaderMenuIcon name="flag" extraClasses="tw:text-secondary" />
|
<HeaderMenuIcon name="flag" extraClasses="tw:text-secondary" />
|
||||||
<span className="tw:hidden tw:lg:inline">
|
<span className="tw:hidden tw:lg:inline">
|
||||||
Flags
|
Flags
|
||||||
<span>({count})</span>
|
<NumberBadge
|
||||||
|
value={count}
|
||||||
|
color={
|
||||||
|
Object.values(flatFlags).some((it) => it.type === 'error') ? 'error' : 'secondary'
|
||||||
|
}
|
||||||
|
/>
|
||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
@ -264,6 +270,17 @@ export const HeaderMenuDraftViewFlags = (props) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NumberBadge = ({ value, color = 'secondary', className = '' }) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`tw:ml-2 tw:inline-flex tw:items-center tw:justify-center tw:rounded-full tw:bg-${color} tw:text-${color}-content tw:text-xs tw:w-5 tw:h-5 tw:leading-none tw:font-semibold ${className}`}
|
||||||
|
style={{ lineHeight: '1rem' }}
|
||||||
|
>
|
||||||
|
{value}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export const HeaderMenuDraftViewIcons = (props) => {
|
export const HeaderMenuDraftViewIcons = (props) => {
|
||||||
const { update, state } = props
|
const { update, state } = props
|
||||||
const { settings = {} } = state // Guard against undefined settings
|
const { settings = {} } = state // Guard against undefined settings
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue