Skip to content

Commit

Permalink
[mui-styled-engine] Add tagged template keys to styled
Browse files Browse the repository at this point in the history
  • Loading branch information
htunnicliff committed Mar 2, 2023
1 parent b1b9ef7 commit f01deb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/mui-styled-engine/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as CSS from 'csstype';
import { StyledComponent, StyledOptions } from '@emotion/styled';
import { StyledComponent, StyledOptions, StyledTags } from '@emotion/styled';
import { PropsOf } from '@emotion/react';

export * from '@emotion/styled';
Expand Down Expand Up @@ -106,7 +106,7 @@ export interface CreateStyledComponent<
SpecificComponentProps extends {} = {},
JSXProps extends {} = {},
T extends object = {},
> {
> extends StyledTags {
(
...styles: Array<Interpolation<ComponentProps & SpecificComponentProps & { theme: T }>>
): StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
Expand Down
4 changes: 4 additions & 0 deletions packages/mui-styled-engine/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export default function styled(tag, options) {
return stylesFactory;
}

Object.keys(emStyled).forEach((tag) => {
styled[tag] = emStyled[tag];
});

// eslint-disable-next-line @typescript-eslint/naming-convention
export const internal_processStyles = (tag, processor) => {
// Emotion attaches all the styles as `__emotion_styles`.
Expand Down
5 changes: 5 additions & 0 deletions packages/mui-styled-engine/src/styled.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from 'chai';
import emStyled from '@emotion/styled';
import styled from './index';

describe('styled', () => {
Expand All @@ -11,4 +12,8 @@ describe('styled', () => {
styled('span')(undefined, { color: 'red' });
}).toErrorDev('MUI: the styled("span")(...args) API requires all its args to be defined');
});

it('has primitive', () => {
expect(styled.div).to.equal(emStyled.div);
});
});

0 comments on commit f01deb3

Please sign in to comment.