Mobile mod label setting component (#3267)
* Mobile mod label setting component * Bump label title size * Dont show disabled label config on mobile --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>zio/stable
parent
877eab0fe3
commit
b622f63918
|
@ -16,6 +16,7 @@ type BreakpointName = keyof typeof breakpoints
|
||||||
const breakpoints: {
|
const breakpoints: {
|
||||||
[key: string]: number
|
[key: string]: number
|
||||||
} = {
|
} = {
|
||||||
|
gtPhone: 500,
|
||||||
gtMobile: 800,
|
gtMobile: 800,
|
||||||
gtTablet: 1300,
|
gtTablet: 1300,
|
||||||
}
|
}
|
||||||
|
@ -26,6 +27,7 @@ function getActiveBreakpoints({width}: {width: number}) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
active: active[active.length - 1],
|
active: active[active.length - 1],
|
||||||
|
gtPhone: active.includes('gtPhone'),
|
||||||
gtMobile: active.includes('gtMobile'),
|
gtMobile: active.includes('gtMobile'),
|
||||||
gtTablet: active.includes('gtTablet'),
|
gtTablet: active.includes('gtTablet'),
|
||||||
}
|
}
|
||||||
|
@ -39,6 +41,7 @@ export const Context = React.createContext<{
|
||||||
theme: themes.Theme
|
theme: themes.Theme
|
||||||
breakpoints: {
|
breakpoints: {
|
||||||
active: BreakpointName | undefined
|
active: BreakpointName | undefined
|
||||||
|
gtPhone: boolean
|
||||||
gtMobile: boolean
|
gtMobile: boolean
|
||||||
gtTablet: boolean
|
gtTablet: boolean
|
||||||
}
|
}
|
||||||
|
@ -47,6 +50,7 @@ export const Context = React.createContext<{
|
||||||
theme: themes.light,
|
theme: themes.light,
|
||||||
breakpoints: {
|
breakpoints: {
|
||||||
active: undefined,
|
active: undefined,
|
||||||
|
gtPhone: false,
|
||||||
gtMobile: false,
|
gtMobile: false,
|
||||||
gtTablet: false,
|
gtTablet: false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
import {getLabelStrings} from '#/lib/moderation/useLabelInfo'
|
import {getLabelStrings} from '#/lib/moderation/useLabelInfo'
|
||||||
|
|
||||||
import {useTheme, atoms as a} from '#/alf'
|
import {useTheme, atoms as a, useBreakpoints} from '#/alf'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {InlineLink} from '#/components/Link'
|
import {InlineLink} from '#/components/Link'
|
||||||
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '../icons/CircleInfo'
|
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '../icons/CircleInfo'
|
||||||
|
@ -29,6 +29,7 @@ export function ModerationLabelPref({
|
||||||
}) {
|
}) {
|
||||||
const {_, i18n} = useLingui()
|
const {_, i18n} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
const {gtPhone} = useBreakpoints()
|
||||||
|
|
||||||
const isGlobalLabel = !labelValueDefinition.definedBy
|
const isGlobalLabel = !labelValueDefinition.definedBy
|
||||||
const {identifier} = labelValueDefinition
|
const {identifier} = labelValueDefinition
|
||||||
|
@ -57,6 +58,7 @@ export function ModerationLabelPref({
|
||||||
adultOnly && !preferences?.moderationPrefs.adultContentEnabled
|
adultOnly && !preferences?.moderationPrefs.adultContentEnabled
|
||||||
// are there any reasons we cant configure this label here?
|
// are there any reasons we cant configure this label here?
|
||||||
const cantConfigure = isGlobalLabel || adultDisabled
|
const cantConfigure = isGlobalLabel || adultDisabled
|
||||||
|
const showConfig = !disabled && (gtPhone || !cantConfigure)
|
||||||
|
|
||||||
// adjust the pref based on whether warn is available
|
// adjust the pref based on whether warn is available
|
||||||
let prefAdjusted = pref
|
let prefAdjusted = pref
|
||||||
|
@ -85,9 +87,19 @@ export function ModerationLabelPref({
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[a.flex_row, a.gap_sm, a.px_lg, a.py_lg, a.justify_between]}>
|
<View
|
||||||
|
style={[
|
||||||
|
a.flex_row,
|
||||||
|
a.gap_md,
|
||||||
|
a.px_lg,
|
||||||
|
a.py_lg,
|
||||||
|
a.justify_between,
|
||||||
|
a.flex_wrap,
|
||||||
|
]}>
|
||||||
<View style={[a.gap_xs, a.flex_1]}>
|
<View style={[a.gap_xs, a.flex_1]}>
|
||||||
<Text style={[a.font_bold]}>{labelStrings.name}</Text>
|
<Text style={[a.font_bold, gtPhone ? a.text_sm : a.text_md]}>
|
||||||
|
{labelStrings.name}
|
||||||
|
</Text>
|
||||||
<Text style={[t.atoms.text_contrast_medium, a.leading_snug]}>
|
<Text style={[t.atoms.text_contrast_medium, a.leading_snug]}>
|
||||||
{labelStrings.description}
|
{labelStrings.description}
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -113,40 +125,51 @@ export function ModerationLabelPref({
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
{disabled ? (
|
|
||||||
<></>
|
{showConfig && (
|
||||||
) : cantConfigure ? (
|
<View style={[gtPhone ? undefined : a.w_full]}>
|
||||||
<View style={[{minHeight: 35}, a.px_sm, a.py_md]}>
|
{cantConfigure ? (
|
||||||
<Text style={[a.font_bold, t.atoms.text_contrast_medium]}>
|
<View
|
||||||
{currentPrefLabel}
|
style={[
|
||||||
</Text>
|
{minHeight: 35},
|
||||||
</View>
|
a.px_md,
|
||||||
) : (
|
a.py_md,
|
||||||
<View style={[{minHeight: 35}]}>
|
a.rounded_sm,
|
||||||
<ToggleButton.Group
|
a.border,
|
||||||
label={_(
|
t.atoms.border_contrast_low,
|
||||||
msg`Configure content filtering setting for category: ${labelStrings.name.toLowerCase()}`,
|
]}>
|
||||||
)}
|
<Text style={[a.font_bold, t.atoms.text_contrast_low]}>
|
||||||
values={[prefAdjusted]}
|
{currentPrefLabel}
|
||||||
onChange={newPref =>
|
</Text>
|
||||||
mutate({
|
</View>
|
||||||
label: identifier,
|
) : (
|
||||||
visibility: newPref[0] as LabelPreference,
|
<View style={[{minHeight: 35}]}>
|
||||||
labelerDid,
|
<ToggleButton.Group
|
||||||
})
|
label={_(
|
||||||
}>
|
msg`Configure content filtering setting for category: ${labelStrings.name.toLowerCase()}`,
|
||||||
<ToggleButton.Button name="ignore" label={ignoreLabel}>
|
)}
|
||||||
{ignoreLabel}
|
values={[prefAdjusted]}
|
||||||
</ToggleButton.Button>
|
onChange={newPref =>
|
||||||
{canWarn && (
|
mutate({
|
||||||
<ToggleButton.Button name="warn" label={warnLabel}>
|
label: identifier,
|
||||||
{warnLabel}
|
visibility: newPref[0] as LabelPreference,
|
||||||
</ToggleButton.Button>
|
labelerDid,
|
||||||
)}
|
})
|
||||||
<ToggleButton.Button name="hide" label={hideLabel}>
|
}>
|
||||||
{hideLabel}
|
<ToggleButton.Button name="ignore" label={ignoreLabel}>
|
||||||
</ToggleButton.Button>
|
{ignoreLabel}
|
||||||
</ToggleButton.Group>
|
</ToggleButton.Button>
|
||||||
|
{canWarn && (
|
||||||
|
<ToggleButton.Button name="warn" label={warnLabel}>
|
||||||
|
{warnLabel}
|
||||||
|
</ToggleButton.Button>
|
||||||
|
)}
|
||||||
|
<ToggleButton.Button name="hide" label={hideLabel}>
|
||||||
|
{hideLabel}
|
||||||
|
</ToggleButton.Button>
|
||||||
|
</ToggleButton.Group>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
Loading…
Reference in New Issue