Skip to content

Commit

Permalink
Tweak radio styles, add Menu.LabelText
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Dec 18, 2024
1 parent 66e4760 commit 8c273ab
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 9 deletions.
49 changes: 49 additions & 0 deletions src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,55 @@ export function ItemIcon({icon: Comp}: ItemIconProps) {
)
}

export function ItemRadio({selected}: {selected: boolean}) {
const t = useTheme()
return (
<View
style={[
a.justify_center,
a.align_center,
a.rounded_full,
t.atoms.border_contrast_high,
{
borderWidth: 1,
height: 24,
width: 24,
},
]}>
{selected ? (
<View
style={[
a.absolute,
a.rounded_full,
{height: 16, width: 16},
selected
? {
backgroundColor: t.palette.primary_500,
}
: {},
]}
/>
) : null}
</View>
)
}

export function LabelText({children}: {children: React.ReactNode}) {
const t = useTheme()
return (
<Text
style={[
a.font_bold,
t.atoms.text_contrast_medium,
{
marginBottom: -10,
},
]}>
{children}
</Text>
)
}

export function Group({children, style}: GroupProps) {
const t = useTheme()
return (
Expand Down
51 changes: 51 additions & 0 deletions src/components/Menu/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,57 @@ export function ItemIcon({icon: Comp, position = 'left'}: ItemIconProps) {
)
}

export function ItemRadio({selected}: {selected: boolean}) {
const t = useTheme()
return (
<View
style={[
a.justify_center,
a.align_center,
a.rounded_full,
t.atoms.border_contrast_high,
{
borderWidth: 1,
height: 24,
width: 24,
},
]}>
{selected ? (
<View
style={[
a.absolute,
a.rounded_full,
{height: 16, width: 16},
selected
? {
backgroundColor: t.palette.primary_500,
}
: {},
]}
/>
) : null}
</View>
)
}

export function LabelText({children}: {children: React.ReactNode}) {
const t = useTheme()
return (
<Text
style={[
a.font_bold,
a.pt_lg,
a.pb_sm,
t.atoms.text_contrast_low,
{
paddingHorizontal: 10,
},
]}>
{children}
</Text>
)
}

export function Group({children}: GroupProps) {
return children
}
Expand Down
23 changes: 14 additions & 9 deletions src/view/com/post-thread/PostThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {Header} from '#/components/Layout'
import {ListFooter, ListMaybePlaceholder} from '#/components/Lists'
import * as Menu from '#/components/Menu'
import {Text} from '#/components/Typography'
import {RadioCircle} from '../util/forms/RadioButton'
import {PostThreadComposePrompt} from './PostThreadComposePrompt'
import {PostThreadItem} from './PostThreadItem'
import {PostThreadLoadMore} from './PostThreadLoadMore'
Expand Down Expand Up @@ -490,7 +489,7 @@ export function PostThread({uri}: {uri: string | undefined}) {

return (
<>
<Header.Outer sticky={true} headerRef={headerRef}>
<Header.Outer headerRef={headerRef}>
<Header.BackButton />
<Header.Content>
<Header.TitleText>
Expand Down Expand Up @@ -572,6 +571,9 @@ let ThreadMenu = ({}: {}): React.ReactNode => {
)}
</Menu.Trigger>
<Menu.Outer>
<Menu.LabelText>
<Trans>Thread display</Trans>
</Menu.LabelText>
<Menu.Group>
<Menu.Item
label={_(msg`Show replies as a list`)}
Expand All @@ -583,7 +585,7 @@ let ThreadMenu = ({}: {}): React.ReactNode => {
<Menu.ItemText>
<Trans>Show replies as a list</Trans>
</Menu.ItemText>
<RadioCircle isSelected={!treeViewEnabled} />
<Menu.ItemRadio selected={!treeViewEnabled} />
</Menu.Item>
<Menu.Item
label={_(msg`Show replies as a tree`)}
Expand All @@ -595,10 +597,13 @@ let ThreadMenu = ({}: {}): React.ReactNode => {
<Menu.ItemText>
<Trans>Show replies as a tree</Trans>
</Menu.ItemText>
<RadioCircle isSelected={treeViewEnabled} />
<Menu.ItemRadio selected={treeViewEnabled} />
</Menu.Item>
</Menu.Group>
<Menu.Divider />
<Menu.LabelText>
<Trans>Reply sorting</Trans>
</Menu.LabelText>
<Menu.Group>
<Menu.Item
label={_(msg`Hot replies first`)}
Expand All @@ -608,7 +613,7 @@ let ThreadMenu = ({}: {}): React.ReactNode => {
<Menu.ItemText>
<Trans>Hot replies first</Trans>
</Menu.ItemText>
<RadioCircle isSelected={sortReplies === 'hotness'} />
<Menu.ItemRadio selected={sortReplies === 'hotness'} />
</Menu.Item>
<Menu.Item
label={_(msg`Oldest replies first`)}
Expand All @@ -618,7 +623,7 @@ let ThreadMenu = ({}: {}): React.ReactNode => {
<Menu.ItemText>
<Trans>Oldest replies first</Trans>
</Menu.ItemText>
<RadioCircle isSelected={sortReplies === 'oldest'} />
<Menu.ItemRadio selected={sortReplies === 'oldest'} />
</Menu.Item>
<Menu.Item
label={_(msg`Newest replies first`)}
Expand All @@ -628,7 +633,7 @@ let ThreadMenu = ({}: {}): React.ReactNode => {
<Menu.ItemText>
<Trans>Newest replies first</Trans>
</Menu.ItemText>
<RadioCircle isSelected={sortReplies === 'newest'} />
<Menu.ItemRadio selected={sortReplies === 'newest'} />
</Menu.Item>
<Menu.Item
label={_(msg`Most-liked replies first`)}
Expand All @@ -638,7 +643,7 @@ let ThreadMenu = ({}: {}): React.ReactNode => {
<Menu.ItemText>
<Trans>Most-liked replies first</Trans>
</Menu.ItemText>
<RadioCircle isSelected={sortReplies === 'most-likes'} />
<Menu.ItemRadio selected={sortReplies === 'most-likes'} />
</Menu.Item>
<Menu.Item
label={_(msg`Random (aka "Poster's Roulette")`)}
Expand All @@ -648,7 +653,7 @@ let ThreadMenu = ({}: {}): React.ReactNode => {
<Menu.ItemText>
<Trans>Random (aka "Poster's Roulette")</Trans>
</Menu.ItemText>
<RadioCircle isSelected={sortReplies === 'random'} />
<Menu.ItemRadio selected={sortReplies === 'random'} />
</Menu.Item>
</Menu.Group>
</Menu.Outer>
Expand Down

0 comments on commit 8c273ab

Please sign in to comment.