Skip to content

Commit

Permalink
[@mantine/demos] Fix mismatch between demo apparent code and real cod…
Browse files Browse the repository at this point in the history
…e in ActionIcon demo (mantinedev#2189)

* ActionIcon:  Fix mismatch between demo apparent code and real code

The real code was changing both the ActionIcon size and the embedded Icon size

* apparent code matches real code instead

* fix prettier
  • Loading branch information
slk333 authored and nmay231 committed Aug 28, 2022
1 parent 89fd225 commit 568dfcd
Showing 1 changed file with 24 additions and 2 deletions.
Expand Up @@ -20,18 +20,40 @@ function Wrapper(props: ActionIconProps) {
);
}

const codeTemplate = (props: string) => `
function computeChildIconSizeProp(props: string) {
if (props.includes('size="xs"')) {
return 'size={12}';
}
if (props.includes('size="sm"')) {
return 'size={14}';
}
if (props.includes('size="md"')) {
return 'size={18}';
}
if (props.includes('size="lg"')) {
return 'size={26}';
}
if (props.includes('size="xl"')) {
return 'size={34}';
}
return 'size={18}';
}

const codeTemplate = (props: string) => {
const childIconSizeProp = computeChildIconSizeProp(props);
return `
import { ActionIcon } from '@mantine/core';
import { IconAdjustments } from '@tabler/icons';
function Demo() {
return (
<ActionIcon${props}>
<IconAdjustments />
<IconAdjustments ${childIconSizeProp} />
</ActionIcon>
);
}
`;
};

export const configurator: MantineDemo = {
type: 'configurator',
Expand Down

0 comments on commit 568dfcd

Please sign in to comment.