Skip to content

Commit

Permalink
Refactor & style
Browse files Browse the repository at this point in the history
  • Loading branch information
khoidt committed Oct 16, 2024
1 parent f548f86 commit 97dc2ec
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
53 changes: 27 additions & 26 deletions src/common/BrokenAndUncertain.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'lodash'
import React from 'react'
import { Form } from 'react-bootstrap'

Expand All @@ -14,34 +15,34 @@ export interface BrokenUncertainProps {
| ((isUncertain: boolean) => void)
}

export function BrokenAndUncertainSwitches({
name,
id = 0,
isBroken = false,
isUncertain = false,
setBroken,
setUncertain,
}: BrokenUncertainProps): JSX.Element {
export function BrokenAndUncertainSwitches(
props: BrokenUncertainProps
): JSX.Element {
return (
<>
<Form.Switch
label={`Broken`}
id={`${id}-${name}_broken`}
aria-label={`${id}-${name}-broken-switch`}
data-testid={`${id}-${name}-broken-switch`}
style={{ marginLeft: '10px' }}
onChange={(event) => setBroken(event.target.checked)}
checked={isBroken}
/>
<Form.Switch
label={`Uncertain`}
id={`${id}-${name}_uncertain`}
aria-label={`${id}-${name}-uncertain-switch`}
data-testid={`${id}-${name}-uncertain-switch`}
style={{ marginLeft: '10px' }}
onChange={(event) => setUncertain(event.target.checked)}
checked={isUncertain}
/>
{getSwitch('broken', props)}
{getSwitch('uncertain', props)}
</>
)
}

function getSwitch(
type: 'broken' | 'uncertain',
props: BrokenUncertainProps
): JSX.Element {
const { name, id } = props
const onChange = props[`set${_.capitalize(type)}`]
const checked = props[`is${_.capitalize(type)}`]
const _id = id ?? 0
return (
<Form.Switch
label={_.capitalize(type)}
id={`${_id}-${name}_${type}`}
aria-label={`${_id}-${name}-${type}-switch`}
data-testid={`${_id}-${name}-${type}-switch`}
style={{ marginLeft: '10px' }}
onChange={(event) => onChange(event.target.checked)}
checked={checked}
/>
)
}
5 changes: 4 additions & 1 deletion src/fragmentarium/ui/info/Colophon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ const ColophonInfo = ({ fragment }: { fragment: Fragment }): JSX.Element => {
const mapToList = (text, index) => <li key={index}>{text}</li>
const individuals = colophon?.individuals && colophon?.individuals.length > 0 && (
<li>
Individuals: <ol>{getIndividualsItems(colophon).map(mapToList)}</ol>
Individuals:{' '}
<ol style={{ listStylePosition: 'outside' }}>
{getIndividualsItems(colophon).map(mapToList)}
</ol>
</li>
)

Expand Down

0 comments on commit 97dc2ec

Please sign in to comment.