generated from garronej/ts-ci
-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useStyles classes should be able to extends new class names #128
Comments
We temporally cast {
makeStyles: <Params = void, RuleNameSubsetReferencableInNestedSelectors extends string = never>(params?: {
name?: string | Record<string, unknown>
uniqId?: string
}) => <RuleName extends string>(
cssObjectByRuleNameOrGetCssObjectByRuleName:
| Record<RuleName, CSSObject>
| ((
theme: Theme,
params: Params,
classes: Record<RuleNameSubsetReferencableInNestedSelectors, string>,
) => Record<RuleNameSubsetReferencableInNestedSelectors | RuleName, CSSObject>),
) => <StyleOverrides extends { classes?: { [key in string]?: string | undefined } }>(
params: Params,
styleOverrides?: {
props: StyleOverrides
ownerState?: Record<string, unknown>
},
) => {
classes: StyleOverrides extends { classes?: { [key in infer ExtraKeys]?: string | undefined } }
? Record<ExtraKeys | RuleName, string>
: Record<RuleName, string>
theme: Theme
css: Css
cx: Cx
}
} |
Hey @Jack-Works, Thank you for the feedback! I understand your usecase, it makes sences. import { useMergedClasses } from "tss-react";
type Props = {
//classes?: { foo?: string; bar?: string; };
classes?: Omit<Partial<ReturnType<typeof useStyles>["classes"]>, "onlyInternal">;
};
function MyTestComponentForMergedClassesInternal(props: Props) {
const { classes } = useStyles({ "color": "pink" }, { props });
//NOTE: Only the classes will be read from props,
//you could write { props: { classes: props.classes } } instead of { props }
//and it would work the same.
return (
<div className={classes.foo}>
<span className={classes.somethingForOverwriting}>
</span>
<span className={classes.onlyIntenal}>
</span>
</div>
);
}
const useStyles = makeStyles<{ color: string; }>()({
"foo": {
"border": "3px dotted black",
"backgroundColor": "red"
}
"somethingForOverwriting": {},
"onlyInternal": {
"color": "red"
}
}); I'll think about it. Glad you found a workaround for now. Best regards |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We're upgrading from v3 to v4 and are happy to find the new feature, but we found some problem with TypeScript.
In our old implementation, we call it
useStyleExtends
and it is implemented in the follow way:This implementation allows us to extend the type of classes in the props. This is our pattern of customizable components.
After migrating to tss-react v4 new API, we found the new API is not sufficient to replace our old one:
The text was updated successfully, but these errors were encountered: