Skip to content

Commit

Permalink
fix: remove full modal prop that sets zero padding
Browse files Browse the repository at this point in the history
  • Loading branch information
macintoshhelper committed Oct 3, 2024
1 parent 4c476d9 commit 8d4f8c6
Showing 1 changed file with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { FileDirectoryIcon } from '@primer/octicons-react';
import {
Tabs, Stack, Heading, Button,
} from '@tokens-studio/ui';
import { Tabs, Stack, Heading, Button } from '@tokens-studio/ui';

Check failure

Code scanning / ESLint

enforce consistent line breaks after opening and before closing braces Error

Expected a line break after this opening brace.

Check failure

Code scanning / ESLint

enforce consistent line breaks after opening and before closing braces Error

Expected a line break before this closing brace.
import React, { useMemo } from 'react';
import { useDispatch, useSelector, useStore } from 'react-redux';
import { useForm, Controller } from 'react-hook-form';
Expand All @@ -24,7 +22,13 @@ import { FormValues } from '../ManageThemesModal/CreateOrEditThemeForm';
import { TokenSetStatus } from '@/constants/TokenSetStatus';
import { ExportTokenSet } from '@/types/ExportTokenSet';

export default function ExportSetsTab({ selectedSets, setSelectedSets }: { selectedSets: ExportTokenSet[], setSelectedSets: (sets: ExportTokenSet[]) => void }) {
export default function ExportSetsTab({
selectedSets,
setSelectedSets,
}: {
selectedSets: ExportTokenSet[];
setSelectedSets: (sets: ExportTokenSet[]) => void;
}) {
const dispatch = useDispatch<Dispatch>();
const closeOnboarding = React.useCallback(() => {
dispatch.uiState.setOnboardingExplainerExportSets(false);
Expand All @@ -35,13 +39,9 @@ export default function ExportSetsTab({ selectedSets, setSelectedSets }: { selec

const store = useStore<RootState>();

const selectedTokenSets = React.useMemo(() => (
usedTokenSetSelector(store.getState())
), [store]);
const selectedTokenSets = React.useMemo(() => usedTokenSetSelector(store.getState()), [store]);

const {
control, getValues, reset,
} = useForm<FormValues>({
const { control, getValues, reset } = useForm<FormValues>({
defaultValues: {
tokenSets: { ...selectedTokenSets },
},
Expand Down Expand Up @@ -70,37 +70,40 @@ export default function ExportSetsTab({ selectedSets, setSelectedSets }: { selec
setPreviousSetSelection(getValues());
}, [getValues]);

const TokenSetThemeItemInput = React.useCallback((props: React.PropsWithChildren<{ item: TreeItem }>) => (
<Controller
name="tokenSets"
control={control}
// this is the only way to do this
// eslint-disable-next-line
render={({ field }) => (
<TokenSetThemeItem
{...props}
value={field.value}
onChange={field.onChange}
/>
)}
/>
), [control]);

const selectedEnabledSets = useMemo(() => selectedSets.filter((set) => set.status === TokenSetStatus.ENABLED), [selectedSets]);
const TokenSetThemeItemInput = React.useCallback(
(props: React.PropsWithChildren<{ item: TreeItem }>) => (
<Controller
name="tokenSets"
control={control}
// this is the only way to do this
// eslint-disable-next-line
render={({ field }) => <TokenSetThemeItem {...props} value={field.value} onChange={field.onChange} />}

Check failure

Code scanning / ESLint

Disallow `.bind()` or arrow functions in JSX props Error

JSX props should not use arrow functions
/>
),
[control],
);

const selectedEnabledSets = useMemo(
() => selectedSets.filter((set) => set.status === TokenSetStatus.ENABLED),
[selectedSets],
);

React.useEffect(() => {
if (!showChangeSets) {
const currentSelectedSets = getValues();
const internalSelectedTokenSets: ExportTokenSet[] = Object.keys(currentSelectedSets.tokenSets).reduce((acc: ExportTokenSet[], curr: string) => {
if (currentSelectedSets.tokenSets[curr] !== TokenSetStatus.DISABLED) {
const tokenSet = {
set: curr,
status: currentSelectedSets.tokenSets[curr],
} as ExportTokenSet;
acc.push(tokenSet);
}
return acc;
}, [] as ExportTokenSet[]);
const internalSelectedTokenSets: ExportTokenSet[] = Object.keys(currentSelectedSets.tokenSets).reduce(
(acc: ExportTokenSet[], curr: string) => {
if (currentSelectedSets.tokenSets[curr] !== TokenSetStatus.DISABLED) {
const tokenSet = {
set: curr,
status: currentSelectedSets.tokenSets[curr],
} as ExportTokenSet;
acc.push(tokenSet);
}
return acc;
},
[] as ExportTokenSet[],
);
setSelectedSets([...internalSelectedTokenSets]);
}
}, [showChangeSets, getValues, setSelectedSets]);
Expand Down Expand Up @@ -134,23 +137,22 @@ export default function ExportSetsTab({ selectedSets, setSelectedSets }: { selec
<span>
{selectedEnabledSets.length}
{' of '}
{allSets.length}
{' '}
{t('exportSetsTab.setsSelectedForExport')}
{allSets.length} {t('exportSetsTab.setsSelectedForExport')}

Check failure

Code scanning / ESLint

Require one JSX element per line Error

{t('exportSetsTab.setsSelectedForExport')} must be placed on a new line
</span>
</Stack>
<Button variant="secondary" size="small" onClick={handleShowChangeSets}>{t('actions.changeSets')}</Button>
<Button variant="secondary" size="small" onClick={handleShowChangeSets}>
{t('actions.changeSets')}
</Button>
</Stack>
</StyledCard>
<Modal
size="fullscreen"
full
compact
isOpen={showChangeSets}
close={handleCancelChangeSets}
backArrow
title="Styles and Variables / Export Sets"
footer={(
footer={
<Stack direction="row" gap={4} justify="between">
<Button variant="secondary" onClick={handleCancelChangeSets}>
{t('actions.cancel')}
Expand All @@ -159,11 +161,9 @@ export default function ExportSetsTab({ selectedSets, setSelectedSets }: { selec
{t('actions.confirm')}
</Button>
</Stack>
)}
}
>
<Heading>
{t('exportSetsTab.changeSetsHeading')}
</Heading>
<Heading>{t('exportSetsTab.changeSetsHeading')}</Heading>
{/* Commenting until we have docs <Link target="_blank" href={docsLinks.sets}>{`${t('generic.learnMore')} – ${t('docs.referenceOnlyMode')}`}</Link> */}
<Stack
direction="column"
Expand Down

0 comments on commit 8d4f8c6

Please sign in to comment.