1
Fork 0
mirror of https://github.com/Steffo99/bluelib.git synced 2024-12-22 19:44:21 +00:00

Add disabled status to the BaseElement

This commit is contained in:
Steffo 2021-08-19 04:22:31 +02:00
parent 0b8edc1d43
commit 605fdc6d66
Signed by: steffo
GPG key ID: 6965406171929D01
12 changed files with 103 additions and 19 deletions

View file

@ -24,6 +24,7 @@ export const Default = props => (
) )
Default.args = { Default.args = {
kind: "div", kind: "div",
disabled: false,
} }
@ -32,3 +33,10 @@ CustomColor.args = {
...Default.args, ...Default.args,
customColor: "#ff7f00", customColor: "#ff7f00",
} }
export const Disabled = Default.bind({})
Disabled.args = {
...Default.args,
disabled: true,
}

View file

@ -11,6 +11,7 @@ export interface BaseElementProps {
kind: Types.ComponentKind, kind: Types.ComponentKind,
bluelibClassNames?: Types.ClassNames, bluelibClassNames?: Types.ClassNames,
customColor?: typeof Color, customColor?: typeof Color,
disabled?: boolean,
[props: string]: any, [props: string]: any,
} }
@ -20,6 +21,9 @@ export function BaseElement({kind, bluelibClassNames, customColor, ...props}: Ba
// Set the Bluelib color // Set the Bluelib color
if(customColor) props.style = {...props.style, ...Colors.colorToBluelibStyle("color", customColor)} if(customColor) props.style = {...props.style, ...Colors.colorToBluelibStyle("color", customColor)}
// Possibly disable the element
if(props.disabled) bluelibClassNames = mergeClassNames(bluelibClassNames, "status-disabled")
// Map regular class names to module class names // Map regular class names to module class names
bluelibClassNames = BluelibMapper.rootToModule(bluelibClassNames) bluelibClassNames = BluelibMapper.rootToModule(bluelibClassNames)
props.className = mergeClassNames(props.className, bluelibClassNames) props.className = mergeClassNames(props.className, bluelibClassNames)

View file

@ -13,6 +13,9 @@ export default {
customColor: { customColor: {
control: {type: "color"}, control: {type: "color"},
}, },
disabled: {
control: {type: "boolean"},
},
}, },
} }
@ -24,7 +27,9 @@ export const Default = props => (
<Box>Third</Box> <Box>Third</Box>
</Chapter> </Chapter>
) )
Default.args = {} Default.args = {
disabled: false,
}
export const AutoWrap = props => ( export const AutoWrap = props => (
@ -46,7 +51,9 @@ export const AutoWrap = props => (
<Box>Fiftheenth</Box> <Box>Fiftheenth</Box>
</Chapter> </Chapter>
) )
AutoWrap.args = {} AutoWrap.args = {
disabled: false,
}
export const ForceWrap = props => ( export const ForceWrap = props => (
@ -58,4 +65,6 @@ export const ForceWrap = props => (
<Box>Fourth</Box> <Box>Fourth</Box>
</Chapter> </Chapter>
) )
ForceWrap.args = {} ForceWrap.args = {
disabled: false,
}

View file

@ -9,6 +9,11 @@ export default {
component: Image, component: Image,
title: "Images/Image", title: "Images/Image",
decorators: [Decorators.Bluelib], decorators: [Decorators.Bluelib],
argTypes: {
disabled: {
control: {type: "boolean"},
},
},
} }
@ -18,6 +23,7 @@ export const NoLimit = props => (
NoLimit.args = { NoLimit.args = {
src: PineappleWithSunglasses, src: PineappleWithSunglasses,
limit: "no", limit: "no",
disabled: false,
} }

View file

@ -12,6 +12,9 @@ export default {
customColor: { customColor: {
control: {type: "color"}, control: {type: "color"},
}, },
disabled: {
control: {type: "boolean"},
},
}, },
} }
@ -38,4 +41,6 @@ export const Default = props => (
</DescriptionList.Value> </DescriptionList.Value>
</DescriptionList> </DescriptionList>
) )
Default.args = {} Default.args = {
disabled: false,
}

View file

@ -12,6 +12,9 @@ export default {
customColor: { customColor: {
control: {type: "color"}, control: {type: "color"},
}, },
disabled: {
control: {type: "boolean"},
},
}, },
} }
@ -24,11 +27,13 @@ export const Unordered = props => (
</List> </List>
) )
Unordered.args = { Unordered.args = {
disabled: false,
ordered: false, ordered: false,
} }
export const Ordered = Unordered.bind({}) export const Ordered = Unordered.bind({})
Ordered.args = { Ordered.args = {
...Unordered.args,
ordered: true, ordered: true,
} }

View file

@ -12,6 +12,9 @@ export default {
customColor: { customColor: {
control: {type: "color"}, control: {type: "color"},
}, },
disabled: {
control: {type: "boolean"},
},
}, },
} }
@ -21,7 +24,9 @@ export const Default = props => (
This is a Box. This is a Box.
</Box> </Box>
) )
Default.args = {} Default.args = {
disabled: false,
}
export const Nested = props => ( export const Nested = props => (
@ -33,7 +38,9 @@ export const Nested = props => (
</Box> </Box>
</Box> </Box>
) )
Nested.args = {} Nested.args = {
disabled: false,
}
export const NestedMultiple = props => ( export const NestedMultiple = props => (
@ -49,4 +56,6 @@ export const NestedMultiple = props => (
</Box> </Box>
</Box> </Box>
) )
NestedMultiple.args = {} NestedMultiple.args = {
disabled: false,
}

View file

@ -12,6 +12,9 @@ export default {
customColor: { customColor: {
control: {type: "color"}, control: {type: "color"},
}, },
disabled: {
control: {type: "boolean"},
},
}, },
} }
@ -21,7 +24,9 @@ export const Default = props => (
This is a Dialog. This is a Dialog.
</Dialog> </Dialog>
) )
Default.args = {} Default.args = {
disabled: false,
}
export const Nested = props => ( export const Nested = props => (
@ -33,7 +38,9 @@ export const Nested = props => (
</Dialog> </Dialog>
</Dialog> </Dialog>
) )
Nested.args = {} Nested.args = {
disabled: false,
}
export const NestedMultiple = props => ( export const NestedMultiple = props => (
@ -49,4 +56,6 @@ export const NestedMultiple = props => (
</Dialog> </Dialog>
</Dialog> </Dialog>
) )
NestedMultiple.args = {} NestedMultiple.args = {
disabled: false,
}

View file

@ -12,6 +12,9 @@ export default {
customColor: { customColor: {
control: {type: "color"}, control: {type: "color"},
}, },
disabled: {
control: {type: "boolean"},
},
}, },
} }
@ -21,7 +24,9 @@ export const Default = props => (
This is a Panel. This is a Panel.
</Panel> </Panel>
) )
Default.args = {} Default.args = {
disabled: false,
}
export const Nested = props => ( export const Nested = props => (
@ -33,7 +38,9 @@ export const Nested = props => (
</Panel> </Panel>
</Panel> </Panel>
) )
Nested.args = {} Nested.args = {
disabled: false,
}
export const NestedMultiple = props => ( export const NestedMultiple = props => (
@ -49,4 +56,6 @@ export const NestedMultiple = props => (
</Panel> </Panel>
</Panel> </Panel>
) )
NestedMultiple.args = {} NestedMultiple.args = {
disabled: false,
}

View file

@ -12,6 +12,9 @@ export default {
customColor: { customColor: {
control: {type: "color"}, control: {type: "color"},
}, },
disabled: {
control: {type: "boolean"},
},
}, },
} }
@ -21,7 +24,9 @@ export const Default = props => (
This is a Parenthesis. This is a Parenthesis.
</Parenthesis> </Parenthesis>
) )
Default.args = {} Default.args = {
disabled: false,
}
export const Nested = props => ( export const Nested = props => (
@ -33,7 +38,9 @@ export const Nested = props => (
</Parenthesis> </Parenthesis>
</Parenthesis> </Parenthesis>
) )
Nested.args = {} Nested.args = {
disabled: false,
}
export const NestedMultiple = props => ( export const NestedMultiple = props => (
@ -49,4 +56,6 @@ export const NestedMultiple = props => (
</Parenthesis> </Parenthesis>
</Parenthesis> </Parenthesis>
) )
NestedMultiple.args = {} NestedMultiple.args = {
disabled: false,
}

View file

@ -26,12 +26,14 @@ Regular.args = {
export const Heavy = Regular.bind({}) export const Heavy = Regular.bind({})
Heavy.args = { Heavy.args = {
...Regular.args,
weight: "heavy", weight: "heavy",
} }
export const Light = Regular.bind({}) export const Light = Regular.bind({})
Light.args = { Light.args = {
...Regular.args,
weight: "light", weight: "light",
} }

View file

@ -12,6 +12,9 @@ export default {
customColor: { customColor: {
control: {type: "color"}, control: {type: "color"},
}, },
disabled: {
control: {type: "boolean"},
},
}, },
} }
@ -84,7 +87,9 @@ export const Brothers = props => (
</Table.Footer> </Table.Footer>
</Table> </Table>
) )
Brothers.args = {} Brothers.args = {
disabled: false,
}
export const TicTacToe = props => ( export const TicTacToe = props => (
@ -129,7 +134,9 @@ export const TicTacToe = props => (
</Table.Body> </Table.Body>
</Table> </Table>
) )
TicTacToe.args = {} TicTacToe.args = {
disabled: false,
}
export const TierList = props => ( export const TierList = props => (
@ -173,6 +180,8 @@ export const TierList = props => (
</Table.Body> </Table.Body>
</Table> </Table>
) )
TicTacToe.args = {} TierList.args = {
disabled: false,
}