Replies: 5 comments 2 replies
-
|
Only component that are disabled can be disabled. You can't eg. disable |
Beta Was this translation helpful? Give feedback.
-
|
I guess that you can just use popular className={cn(
disabled && 'opacity-50',
!disabled && 'opacity-100',
'bg-violet-500'
)} |
Beta Was this translation helpful? Give feedback.
-
|
I want to expose my own component that should by styleable with uniwind. As a user of the component, it can end up as disabled, and i want the “disabled:” prefix to work. Note that how the component interprets “isDisabled” should be an internal detail. Assume though for this discussion that my component is just backed by a regular View. |
Beta Was this translation helpful? Give feedback.
-
|
An alternative way of looking at this is how do we support |
Beta Was this translation helpful? Give feedback.
-
|
Expanding on this further, to hopefully get my point across. Let's say we haven't integrated uniwind yet and just working on import { Gesture, GestureDetector } from 'react-native-gesture-handler';
// A button that executes an action on pinch
type Props = {
onPinch?: () => void;
isDisabled?: boolean;
style?: ViewStyle
} & ViewProps;
function MyPinchButton({ onPinch, isDisabled, style, ...rest }: Props): {
let gesture = Gesture.Pinch()...onEnd(/* if !isDisabled call onPinch */);
return (<GestureDetector gesture={gesture}><View style={style} {...rest}/></GestureDetector>);
}Now assume that as a user of this component, we'd want to style a
But as the component author it's nicer if we change Props to accept a style function instead: // A button that executes an action on pinch
type Props = {
...
style?: ViewStyle | ({ isDisabled }) => ViewStyle;
} & ViewProps;
function MyPinchButton({ onPinch, isDisabled = false, style: _style, ...rest }: Props): {
// ...
let style = typeof _style === "function" : _style({ isDisabled }) : _style;
return (<GestureDetector gesture={gesture}><View style={style} {...rest}/></GestureDetector>);
}So say I want to to support uniwind style classNames. While it's trivial to be able to support say:
How can I let the user also support Two ways I can logically think of how (A) Using
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Say we have a component:
function MyInput({ isDisabled, className }) { ... }And we want to be able to let the user pass in a className:
disabled:bg-yellow-100. How can we do this? Assume thatMyInputis not backed byTextInput(which does map it here), but something fully custom.Beta Was this translation helpful? Give feedback.
All reactions