Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
mayagbarnes committed Aug 16, 2023
1 parent 9745e18 commit 7b4022c
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions frontend/lib/src/components/shared/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ class Radio extends React.PureComponent<Props, State> {
const options = [...this.props.options]
const captions = [...this.props.captions]

const spacerNeeded = (caption: string) => {

Check warning on line 85 in frontend/lib/src/components/shared/Radio/Radio.tsx

View workflow job for this annotation

GitHub Actions / js_test

Missing return type on function
// When captions are provided for only some options in horizontal
// layout we need to add a spacer for the options without captions
const spacer = caption == "" && horizontal && captions.length > 0
return spacer ? "&nbsp;" : caption
}

if (options.length === 0) {
options.push("No options to select.")
disabled = true
Expand All @@ -107,6 +114,13 @@ class Radio extends React.PureComponent<Props, State> {
align={horizontal ? ALIGN.horizontal : ALIGN.vertical}
aria-label={label}
data-testid="stRadioGroup"
overrides={{
RadioGroupRoot: {
style: {
gap: "0.5rem",
},
},
}}
>
{options.map((option: string, index: number) => (
<UIRadio
Expand All @@ -119,9 +133,9 @@ class Radio extends React.PureComponent<Props, State> {
}: {
$isFocusVisible: boolean
}) => ({
marginBottom: "0.5rem",
marginBottom: 0,
marginTop: 0,
marginRight: "1rem",
marginRight: "0.5rem",
// Make left and right padding look the same visually.
paddingLeft: 0,
alignItems: "start",
Expand Down Expand Up @@ -169,14 +183,12 @@ class Radio extends React.PureComponent<Props, State> {
largerLabel
disableLinks
/>
{captions[index] && (
<StreamlitMarkdown
source={captions[index]}
allowHTML={false}
isCaption
isLabel
/>
)}
<StreamlitMarkdown
source={spacerNeeded(captions[index])}
allowHTML={false}
isCaption
isLabel
/>
</UIRadio>
))}
</RadioGroup>
Expand Down

0 comments on commit 7b4022c

Please sign in to comment.