Skip to content

Commit

Permalink
[core] Improve support for extended props in theme (#25934)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicasas authored Apr 26, 2021
1 parent f3e4ac4 commit 1d3b2af
Show file tree
Hide file tree
Showing 64 changed files with 361 additions and 197 deletions.
5 changes: 4 additions & 1 deletion docs/pages/api-docs/autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@
"renderTags": { "type": { "name": "func" } },
"selectOnFocus": { "type": { "name": "bool" }, "default": "!props.freeSolo" },
"size": {
"type": { "name": "enum", "description": "'medium'<br>&#124;&nbsp;'small'" },
"type": {
"name": "union",
"description": "'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
"sx": { "type": { "name": "object" } },
Expand Down
9 changes: 6 additions & 3 deletions docs/pages/api-docs/checkbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "enum",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'"
"name": "union",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
},
"default": "'secondary'"
},
Expand All @@ -22,7 +22,10 @@
"onChange": { "type": { "name": "func" } },
"required": { "type": { "name": "bool" } },
"size": {
"type": { "name": "enum", "description": "'medium'<br>&#124;&nbsp;'small'" },
"type": {
"name": "union",
"description": "'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
"sx": { "type": { "name": "object" } },
Expand Down
9 changes: 6 additions & 3 deletions docs/pages/api-docs/chip.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"clickable": { "type": { "name": "bool" } },
"color": {
"type": {
"name": "enum",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'"
"name": "union",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
},
"default": "'default'"
},
Expand All @@ -18,7 +18,10 @@
"label": { "type": { "name": "node" } },
"onDelete": { "type": { "name": "func" } },
"size": {
"type": { "name": "enum", "description": "'medium'<br>&#124;&nbsp;'small'" },
"type": {
"name": "union",
"description": "'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
"sx": { "type": { "name": "object" } },
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/api-docs/fab.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "enum",
"description": "'default'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'"
"name": "union",
"description": "'default'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
},
"default": "'default'"
},
Expand All @@ -16,8 +16,8 @@
"href": { "type": { "name": "string" } },
"size": {
"type": {
"name": "enum",
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'"
"name": "union",
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'large'"
},
Expand Down
7 changes: 6 additions & 1 deletion docs/pages/api-docs/filled-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"autoComplete": { "type": { "name": "string" } },
"autoFocus": { "type": { "name": "bool" } },
"classes": { "type": { "name": "object" } },
"color": { "type": { "name": "enum", "description": "'primary'<br>&#124;&nbsp;'secondary'" } },
"color": {
"type": {
"name": "union",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
}
},
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableUnderline": { "type": { "name": "bool" } },
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/api-docs/icon.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "enum",
"description": "'action'<br>&#124;&nbsp;'disabled'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'"
"name": "union",
"description": "'action'<br>&#124;&nbsp;'disabled'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
},
"default": "'inherit'"
},
"component": { "type": { "name": "elementType" } },
"fontSize": {
"type": {
"name": "enum",
"description": "'inherit'<br>&#124;&nbsp;'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'"
"name": "union",
"description": "'inherit'<br>&#124;&nbsp;'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
Expand Down
7 changes: 6 additions & 1 deletion docs/pages/api-docs/input-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"autoComplete": { "type": { "name": "string" } },
"autoFocus": { "type": { "name": "bool" } },
"classes": { "type": { "name": "object" } },
"color": { "type": { "name": "enum", "description": "'primary'<br>&#124;&nbsp;'secondary'" } },
"color": {
"type": {
"name": "union",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
}
},
"components": {
"type": { "name": "shape", "description": "{ Input?: elementType, Root?: elementType }" },
"default": "{}"
Expand Down
7 changes: 6 additions & 1 deletion docs/pages/api-docs/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"autoComplete": { "type": { "name": "string" } },
"autoFocus": { "type": { "name": "bool" } },
"classes": { "type": { "name": "object" } },
"color": { "type": { "name": "enum", "description": "'primary'<br>&#124;&nbsp;'secondary'" } },
"color": {
"type": {
"name": "union",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
}
},
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableUnderline": { "type": { "name": "bool" } },
Expand Down
7 changes: 6 additions & 1 deletion docs/pages/api-docs/outlined-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"autoComplete": { "type": { "name": "string" } },
"autoFocus": { "type": { "name": "bool" } },
"classes": { "type": { "name": "object" } },
"color": { "type": { "name": "enum", "description": "'primary'<br>&#124;&nbsp;'secondary'" } },
"color": {
"type": {
"name": "union",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
}
},
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"endAdornment": { "type": { "name": "node" } },
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/api-docs/pagination-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "enum",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'standard'"
"name": "union",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'standard'<br>&#124;&nbsp;string"
},
"default": "'standard'"
},
Expand All @@ -18,8 +18,8 @@
},
"size": {
"type": {
"name": "enum",
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'"
"name": "union",
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/api-docs/pagination.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "enum",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'standard'"
"name": "union",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'standard'<br>&#124;&nbsp;string"
},
"default": "'standard'"
},
Expand All @@ -30,8 +30,8 @@
"siblingCount": { "type": { "name": "custom", "description": "integer" }, "default": "1" },
"size": {
"type": {
"name": "enum",
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'"
"name": "union",
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
Expand Down
9 changes: 6 additions & 3 deletions docs/pages/api-docs/radio.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "enum",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'"
"name": "union",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
},
"default": "'secondary'"
},
Expand All @@ -20,7 +20,10 @@
"onChange": { "type": { "name": "func" } },
"required": { "type": { "name": "bool" } },
"size": {
"type": { "name": "enum", "description": "'medium'<br>&#124;&nbsp;'small'" },
"type": {
"name": "union",
"description": "'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
"sx": { "type": { "name": "object" } },
Expand Down
5 changes: 4 additions & 1 deletion docs/pages/api-docs/slider.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"aria-valuetext": { "type": { "name": "custom", "description": "string" } },
"classes": { "type": { "name": "object" } },
"color": {
"type": { "name": "enum", "description": "'primary'<br>&#124;&nbsp;'secondary'" },
"type": {
"name": "union",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
},
"default": "'primary'"
},
"component": { "type": { "name": "elementType" } },
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/api-docs/svg-icon.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "enum",
"description": "'action'<br>&#124;&nbsp;'disabled'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'"
"name": "union",
"description": "'action'<br>&#124;&nbsp;'disabled'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
},
"default": "'inherit'"
},
"component": { "type": { "name": "elementType" } },
"fontSize": {
"type": {
"name": "enum",
"description": "'inherit'<br>&#124;&nbsp;'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'"
"name": "union",
"description": "'inherit'<br>&#124;&nbsp;'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
Expand Down
9 changes: 6 additions & 3 deletions docs/pages/api-docs/switch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "enum",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'"
"name": "union",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
},
"default": "'secondary'"
},
Expand All @@ -27,7 +27,10 @@
"onChange": { "type": { "name": "func" } },
"required": { "type": { "name": "bool" } },
"size": {
"type": { "name": "enum", "description": "'medium'<br>&#124;&nbsp;'small'" },
"type": {
"name": "union",
"description": "'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
"sx": { "type": { "name": "object" } },
Expand Down
5 changes: 4 additions & 1 deletion docs/pages/api-docs/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"default": "'normal'"
},
"size": {
"type": { "name": "enum", "description": "'medium'<br>&#124;&nbsp;'small'" },
"type": {
"name": "union",
"description": "'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
"stickyHeader": { "type": { "name": "bool" } },
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/api-docs/toggle-button-group.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
},
"size": {
"type": {
"name": "enum",
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'"
"name": "union",
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/api-docs/toggle-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"selected": { "type": { "name": "bool" } },
"size": {
"type": {
"name": "enum",
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'"
"name": "union",
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
Expand Down
24 changes: 9 additions & 15 deletions framer/Material-UI.framerfx/code/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ import FormControlLabel from '@material-ui/core/FormControlLabel';

interface Props {
checked: boolean;
color: 'default' | 'primary' | 'secondary';
defaultChecked?: boolean;
disabled: boolean;
size: 'medium' | 'small';
label: string;
width: number | string;
height: number;
onChange?: React.ChangeEventHandler<HTMLInputElement>;
}

export function Checkbox(props: Props): JSX.Element {
const { checked: checkedProp, label, onChange, size, ...other } = props;
const {
checked: checkedProp,
label,
onChange,
// @ts-ignore -- untyped
size,
...other
} = props;

const [checked, setChecked] = React.useState(false);

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
Expand All @@ -37,9 +43,7 @@ export function Checkbox(props: Props): JSX.Element {

Checkbox.defaultProps = {
checked: false,
color: 'secondary' as 'secondary',
disabled: false,
size: 'medium' as 'medium',
label: 'Checkbox',
width: 100,
height: 42,
Expand All @@ -50,11 +54,6 @@ addPropertyControls(Checkbox, {
type: ControlType.Boolean,
title: 'Checked',
},
color: {
type: ControlType.Enum,
title: 'Color',
options: ['default', 'primary', 'secondary'],
},
defaultChecked: {
type: ControlType.Boolean,
title: 'Default checked',
Expand All @@ -63,11 +62,6 @@ addPropertyControls(Checkbox, {
type: ControlType.Boolean,
title: 'Disabled',
},
size: {
type: ControlType.Enum,
title: 'Size',
options: ['medium', 'small'],
},
label: {
type: ControlType.String,
title: 'Label',
Expand Down
Loading

0 comments on commit 1d3b2af

Please sign in to comment.