Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brijeshb42 committed Jun 4, 2024
1 parent e79bf7e commit 3c2b921
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 407 deletions.
9 changes: 0 additions & 9 deletions packages/pigment-css-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,6 @@
"require": "./build/Box.js",
"default": "./build/Box.js"
},
"./createTransitions": {
"types": "./build/createTransitions.d.ts",
"import": {
"types": "./build/createTransitions.d.mts",
"default": "./build/createTransitions.mjs"
},
"require": "./build/createTransitions.js",
"default": "./build/createTransitions.js"
},
"./RtlProvider": {
"types": "./build/RtlProvider.d.ts",
"import": {
Expand Down
161 changes: 0 additions & 161 deletions packages/pigment-css-react/src/createTransitions.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/pigment-css-react/src/processors/useTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ export class UseThemeProcessor extends BaseProcessor {
}

get value(): Expression {
return this.astService.stringLiteral(this.className);
return this.astService.nullLiteral();
}
}
4 changes: 3 additions & 1 deletion packages/pigment-css-react/src/useTheme.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export default function useTheme() {
return null;
throw new Error(
`${process.env.PACKAGE_NAME}: You were trying to call "useTheme" function without configuring your bundler. Make sure to install the bundler specific plugin and use it. @pigment-css/vite-plugin for Vite integration or @pigment-css/nextjs-plugin for Next.js integration.`,
);
}
4 changes: 0 additions & 4 deletions packages/pigment-css-react/src/utils/extendTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ export function extendTheme<
[this.getColorSchemeSelector(colorScheme)]: styles,
};
};
finalTheme.unstable_args = {
breakpoints: theme.breakpoints,
transitions: theme.transitions,
};

return finalTheme;
}
121 changes: 1 addition & 120 deletions packages/pigment-css-react/tests/useTheme/fixtures/useTheme.input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,124 +2,5 @@ import { useTheme } from '../zero-styled';

export const Fade = React.forwardRef(function Fade(props, ref) {
const theme = useTheme();
const defaultTimeout = {
enter: theme.transitions.duration.enteringScreen,
exit: theme.transitions.duration.leavingScreen,
};

const {
addEndListener,
appear = true,
children,
easing,
in: inProp,
onEnter,
onEntered,
onEntering,
onExit,
onExited,
onExiting,
style,
timeout = defaultTimeout,
// eslint-disable-next-line react/prop-types
TransitionComponent = Transition,
...other
} = props;

const enableStrictModeCompat = true;
const nodeRef = React.useRef(null);
const handleRef = useForkRef(nodeRef, children.ref, ref);

const normalizedTransitionCallback = (callback) => (maybeIsAppearing) => {
if (callback) {
const node = nodeRef.current;

// onEnterXxx and onExitXxx callbacks have a different arguments.length value.
if (maybeIsAppearing === undefined) {
callback(node);
} else {
callback(node, maybeIsAppearing);
}
}
};

const handleEntering = normalizedTransitionCallback(onEntering);

const handleEnter = normalizedTransitionCallback((node, isAppearing) => {
reflow(node); // So the animation always start from the start.

const transitionProps = getTransitionProps(
{ style, timeout, easing },
{
mode: 'enter',
},
);

node.style.webkitTransition = theme.transitions.create('opacity', transitionProps);
node.style.transition = theme.transitions.create('opacity', transitionProps);

if (onEnter) {
onEnter(node, isAppearing);
}
});

const handleEntered = normalizedTransitionCallback(onEntered);

const handleExiting = normalizedTransitionCallback(onExiting);

const handleExit = normalizedTransitionCallback((node) => {
const transitionProps = getTransitionProps(
{ style, timeout, easing },
{
mode: 'exit',
},
);

node.style.webkitTransition = theme.transitions.create('opacity', transitionProps);
node.style.transition = theme.transitions.create('opacity', transitionProps);

if (onExit) {
onExit(node);
}
});

const handleExited = normalizedTransitionCallback(onExited);

const handleAddEndListener = (next) => {
if (addEndListener) {
// Old call signature before `react-transition-group` implemented `nodeRef`
addEndListener(nodeRef.current, next);
}
};

return (
<TransitionComponent
appear={appear}
in={inProp}
nodeRef={enableStrictModeCompat ? nodeRef : undefined}
onEnter={handleEnter}
onEntered={handleEntered}
onEntering={handleEntering}
onExit={handleExit}
onExited={handleExited}
onExiting={handleExiting}
addEndListener={handleAddEndListener}
timeout={timeout}
{...other}
>
{(state, childProps) => {
return React.cloneElement(children, {
style: {
opacity: 0,
visibility: state === 'exited' && !inProp ? 'hidden' : undefined,
...styles[state],
...style,
...children.props.style,
},
ref: handleRef,
...childProps,
});
}}
</TransitionComponent>
);
return <div style={{ backgroundColor: theme.palette.primary.main }} />;
});
Loading

0 comments on commit 3c2b921

Please sign in to comment.