Skip to content

Commit

Permalink
feat(core): add i18n primitives to GridArrayInput + ListArrayInput
Browse files Browse the repository at this point in the history
  • Loading branch information
RitaDias committed Aug 24, 2023
1 parent 3ffcc85 commit a0cd4fd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {ArrayOfObjectsItem} from '../../../../members'
import {createProtoArrayValue} from '../createProtoArrayValue'
import {UploadTargetCard} from '../../common/UploadTargetCard'
import {ArrayOfObjectsFunctions} from '../ArrayOfObjectsFunctions'
import {useTranslation} from '../../../../../i18n'
import {GridItem} from './GridItem'
import {ErrorItem} from './ErrorItem'

Expand All @@ -32,6 +33,7 @@ export function GridArrayInput<Item extends ObjectItem>(props: ArrayOfObjectsInp
schemaType,
value = EMPTY,
} = props
const {t} = useTranslation()

const handlePrepend = useCallback(
(item: Item) => {
Expand Down Expand Up @@ -69,7 +71,7 @@ export function GridArrayInput<Item extends ObjectItem>(props: ArrayOfObjectsInp
{members?.length === 0 && (
<Card padding={3} border style={{borderStyle: 'dashed'}} radius={2}>
<Text align="center" muted size={1}>
{schemaType.placeholder || <>No items</>}
{schemaType.placeholder || <>{t('arrayInput.no-items-label')}</>}
</Text>
</Card>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {ArrayOfObjectsItem} from '../../../../members'
import {createProtoArrayValue} from '../createProtoArrayValue'
import {UploadTargetCard} from '../../common/UploadTargetCard'
import {ArrayOfObjectsFunctions} from '../ArrayOfObjectsFunctions'
import {useTranslation} from '../../../../../i18n'
import {useVirtualizerScrollInstance} from './useVirtualizerScrollInstance'
import {ErrorItem} from './ErrorItem'
import {useMemoCompare} from './useMemoCompare'
Expand Down Expand Up @@ -45,6 +46,7 @@ export function ListArrayInput<Item extends ObjectItem>(props: ArrayOfObjectsInp
schemaType,
value = EMPTY,
} = props
const {t} = useTranslation()

// Stores the index of the item being dragged
const [activeDragItemIndex, setActiveDragItemIndex] = useState<number | null>(null)
Expand Down Expand Up @@ -197,7 +199,7 @@ export function ListArrayInput<Item extends ObjectItem>(props: ArrayOfObjectsInp
{members.length === 0 ? (
<Card padding={3} border style={{borderStyle: 'dashed'}} radius={2}>
<Text align="center" muted size={1}>
{schemaType.placeholder || <>No items</>}
{schemaType.placeholder || <>{t('arrayInput.no-items-label')}</>}
</Text>
</Card>
) : (
Expand Down
3 changes: 3 additions & 0 deletions packages/sanity/src/core/i18n/bundles/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export const studioLocaleStrings = {

/** --- Array Input --- */

/** Label for when the array input doesn't have any items */
'arrayInput.no-items-label': 'No items',

/** Label for removing action when an array item has an error */
'arrayInput.action.remove': 'Remove',

Expand Down

0 comments on commit a0cd4fd

Please sign in to comment.