Skip to content
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

chore: Updated unique id generation for classnames #2913

Merged
11 changes: 10 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {DocsPage, DocsContainer} from '@storybook/addon-docs';
import React from 'react';
import {DocsPage, DocsContainer, Unstyled} from '@storybook/addon-docs';
import 'cypress-storybook/react';
import routes from './routes';

Expand All @@ -12,6 +13,14 @@ import '@workday/canvas-tokens-web/css/system/_variables.css';
// set routes on window for testing the validity of the routes
window.__routes = routes;

const UnstyledDocsContainer = ({children, ...props}) => {
return (
<DocsContainer {...props}>
<Unstyled>{children}</Unstyled>
</DocsContainer>
);
};

export const decorators = [CanvasProviderDecorator];

export const parameters = {
Expand Down
2 changes: 1 addition & 1 deletion modules/docs/lib/ExampleCodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const ExampleCodeBlock = ({code}: any) => {

return (
<div {...cardStencil({opened: isCodeDisplayed})}>
<Card data-part="example-block">
<Card data-part="example-block" className="sb-unstyled">
<Card.Body>
{React.createElement(code)}
{code && (
Expand Down
8 changes: 8 additions & 0 deletions modules/docs/mdx/12.0-UPGRADE-GUIDE.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ A note to the reader:

- [Canvas Tokens](#canvas-tokens)
- [Codemod](#codemod)
- [Styling Updates](#styling-updates)
- [Compatability Mode](#compatability-mode)
- [Deprecations](#deprecations)
- [Removals](#removals)
- [InputIconContainer](#inputiconcontainer)
Expand Down Expand Up @@ -69,6 +71,12 @@ In v12, we have done some infrastructure updates with moving to Webpack 5 and St
these updates has come some formatting issues after running our codemods. We recommend running a
formatter to address the format issues that have been introduced in v12.

## Styling Updates

### Compatability Mode

In v12, we have addressed a style merge issue with removing forced compatibility mode. For more information on this change, please read our [discussion](https://github.com/Workday/canvas-kit/discussions/2893).

## Deprecations

We add the [@deprecated](https://jsdoc.app/tags-deprecated.html) JSDoc tag to code we plan to remove
Expand Down
3 changes: 1 addition & 2 deletions modules/react/layout/spec/mergeStyles.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ describe('mergeStyles', () => {

expect(screen.getByTestId('base')).toHaveStyle({padding: padding.styleAttribute});
});
// Skipping this for now while we enable compat mode to run all the time
it.skip('should allow the cs prop to override base styles', () => {
it('should allow the cs prop to override base styles', () => {
const overrideStyles = createStyles({
padding: padding.createStyles,
});
Expand Down
3 changes: 1 addition & 2 deletions modules/styling-transform/lib/utils/createStyleObjectNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {generateUniqueId} from '@workday/canvas-kit-styling';

import {prettyStringify} from './stylisFns';
import {NestedStyleObject, TransformerContext} from './types';
import {getHash} from './getHash';

/**
* Creates an AST node representation of the passed in `styleObj`, but in the format of `{name:
Expand Down Expand Up @@ -65,7 +64,7 @@ export function serializeStyles(
) {
const {getFileName, styles, cache, names, extractedNames} = context;
const fileName = getFileName(node.getSourceFile().fileName);
const hash = getHash(node, context);
const hash = generateUniqueId(); //getHash(node, context);
const serialized = {...serializedStylesEmotion([input]), name: hash} as ReturnType<
typeof serializedStylesEmotion
>;
Expand Down
2 changes: 1 addition & 1 deletion modules/styling/lib/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ export function handleCsProp<
// In order to allow everyone to use createStyles and createStencil without worrying about style merge issues, we're going
// to enable compat mode all the time. We'll look into possible out-of-order execution issues in the future and plan to re-enable
// full static mode (for better performance) once we know why this is happening and have a proper workaround.
let shouldRuntimeMergeStyles = true;
let shouldRuntimeMergeStyles = false;

// The order is intentional. The `className` should go first, then the `cs` prop. If we don't do
// runtime merging, this order doesn't actually matter because the browser doesn't care the order
Expand Down
4 changes: 1 addition & 3 deletions modules/styling/spec/cs.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1222,9 +1222,7 @@ describe('handleCsProp', () => {
expect(screen.getByTestId('base')).toHaveStyle({padding: padding.styleAttribute});
});

// While we have compat mode enabled, we'll skip these tests. The class generated comes from emotion and
//we have no way of validating the correct class.
it.skip('should allow the cs prop to override base styles', () => {
it('should allow the cs prop to override base styles', () => {
const overrideStyles = createStyles({
padding: padding.createStyles,
});
Expand Down
Loading