Skip to content

Commit

Permalink
Merge branch 'styled-components' of https://github.com/cmpsr/composer
Browse files Browse the repository at this point in the history
…into styled-expandabletextfield

* 'styled-components' of https://github.com/cmpsr/composer:
  Styled ExpandableTextfieldIcon (#189)
  Use typescript config in tests and stories too (#191)
  Image customCss Implementation (#186)
  Styled TextField (#185)

# Conflicts:
#	packages/styled-components/src/components/primitives/Form/ExpandableTextField/ExpandableTextField.styled.ts
#	packages/styled-components/src/components/primitives/index.ts
  • Loading branch information
guilean committed Nov 3, 2020
2 parents d2663d1 + b1bd4a3 commit a673b33
Show file tree
Hide file tree
Showing 52 changed files with 773 additions and 155 deletions.
1 change: 0 additions & 1 deletion packages/styled-components/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"module-resolver",
{
"alias": {
"src": "./src",
"components": "./src/components",
"utils": "./src/utils",
"tests": "./config/jest",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import styled from 'styled-components';
import { getTheme } from 'utils/getTheme';
import { StyledCssProps } from 'components/Components.styled.types';
import { withCustomCss } from 'utils/withCustomCss';
import { customCss } from 'utils/customCss';

export const StyledBox = withCustomCss(styled.div<StyledCssProps>`
export const StyledBox = styled.div<StyledCssProps>`
&.screen {
width: 100vw;
height: 100vh;
Expand All @@ -19,4 +19,5 @@ export const StyledBox = withCustomCss(styled.div<StyledCssProps>`
margin-left: auto;
max-width: ${(props) => getTheme(props).breakpoints.xl};
}
`);
${(props) => customCss(props)}
`;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Box } from '.';
import 'jest-styled-components';

describe('Box', () => {
const testId = 'box';
Expand All @@ -14,9 +15,11 @@ describe('Box', () => {
expect(box).toHaveClass('foo');
});
it('should render custom css', () => {
render(<Box customCss="customCss" />);
render(<Box customCss="color: violet" />);
const box = screen.getByTestId(testId);
expect(box).toHaveClass('custom');
expect(box).toHaveStyleRule('color', 'violet', {
modifier: '&&&',
});
});
it('should render screen size', () => {
render(<Box size={Box.Sizes.Screen}>foo</Box>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const TwoColumnsDesktopOneMobileWithImages = () => (
title="Create an Out-of-this-World website with this headline"
subtitle="We are right now on the verge of finding out whether there is life elsewhere in the universe, and there are three ways we could find it."
asset={{
contentType: 'image',
contentType: Asset.ContentType.Image,
title: 'Image Title',
url: 'https://avatars0.githubusercontent.com/u/67131017?s=200&v=4',
}}
Expand All @@ -102,7 +102,7 @@ export const TwoColumnsDesktopOneMobileWithImages = () => (
title="Create an Out-of-this-World website with this headline"
subtitle="We are right now on the verge of finding out whether there is life elsewhere in the universe, and there are three ways we could find it."
asset={{
contentType: 'image',
contentType: Asset.ContentType.Image,
title: 'Image Title',
url: 'https://avatars0.githubusercontent.com/u/67131017?s=200&v=4',
}}
Expand All @@ -111,7 +111,7 @@ export const TwoColumnsDesktopOneMobileWithImages = () => (
title="Create an Out-of-this-World website with this headline"
subtitle="We are right now on the verge of finding out whether there is life elsewhere in the universe, and there are three ways we could find it."
asset={{
contentType: 'image',
contentType: Asset.ContentType.Image,
title: 'Image Title',
url: 'https://avatars0.githubusercontent.com/u/67131017?s=200&v=4',
}}
Expand All @@ -120,7 +120,7 @@ export const TwoColumnsDesktopOneMobileWithImages = () => (
title="Create an Out-of-this-World website with this headline"
subtitle="We are right now on the verge of finding out whether there is life elsewhere in the universe, and there are three ways we could find it."
asset={{
contentType: 'image',
contentType: Asset.ContentType.Image,
title: 'Image Title',
url: 'https://avatars0.githubusercontent.com/u/67131017?s=200&v=4',
}}
Expand All @@ -146,42 +146,42 @@ export const Playground = () => (
asset={{
title: '',
url: 'https://avatars0.githubusercontent.com/u/67131017?s=200&v=4',
contentType: 'image',
contentType: Asset.ContentType.Image,
}}
/>
<Asset
asset={{
title: '',
url: 'https://avatars0.githubusercontent.com/u/67131017?s=200&v=4',
contentType: 'image',
contentType: Asset.ContentType.Image,
}}
/>
<Asset
asset={{
title: '',
url: 'https://avatars0.githubusercontent.com/u/67131017?s=200&v=4',
contentType: 'image',
contentType: Asset.ContentType.Image,
}}
/>
<Asset
asset={{
title: '',
url: 'https://avatars0.githubusercontent.com/u/67131017?s=200&v=4',
contentType: 'image',
contentType: Asset.ContentType.Image,
}}
/>
<Asset
asset={{
title: '',
url: 'https://avatars0.githubusercontent.com/u/67131017?s=200&v=4',
contentType: 'image',
contentType: Asset.ContentType.Image,
}}
/>
<Asset
asset={{
title: '',
url: 'https://avatars0.githubusercontent.com/u/67131017?s=200&v=4',
contentType: 'image',
contentType: Asset.ContentType.Image,
}}
/>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import styled from 'styled-components';
import { withCustomCss } from 'utils/withCustomCss';
import { customCss } from 'utils/customCss';
import { StyledCssProps } from 'components/Components.styled.types';

export const StyledGrid = withCustomCss(styled.div`
export const StyledGrid = styled.div<StyledCssProps>`
display: grid;
`);
${(props) => customCss(props)}
`;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Grid } from './Grid';
import 'jest-styled-components';

describe('Grid', () => {
it('should render', () => {
Expand All @@ -17,8 +18,10 @@ describe('Grid', () => {
expect(grid).toHaveClass('foo');
});
it('should render custom CSS as a class', () => {
const { getByTestId } = render(<Grid customCss="customCss">foo</Grid>);
const { getByTestId } = render(<Grid customCss="color: violet">foo</Grid>);
const grid = getByTestId('grid');
expect(grid).toHaveClass('custom');
expect(grid).toHaveStyleRule('color', 'violet', {
modifier: '&&&',
});
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import styled from 'styled-components';
import { withCustomCss } from 'utils/withCustomCss';
import { customCss } from 'utils/customCss';
import { StyledCssProps } from 'components/Components.styled.types';

export const StyledSection = withCustomCss(styled.section<StyledCssProps>`
export const StyledSection = styled.section<StyledCssProps>`
margin-bottom: 1rem;
`);
${(props) => customCss(props)}
`;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Section } from '.';
import 'jest-styled-components';

describe('Section', () => {
it('should render with children', () => {
Expand All @@ -13,8 +14,10 @@ describe('Section', () => {
expect(section).toHaveClass('foo');
});
it('should render custom css', () => {
render(<Section customCss="customCss" />);
render(<Section customCss="color: violet" />);
const section = screen.getByTestId('section');
expect(section).toHaveClass('custom');
expect(section).toHaveStyleRule('color', 'violet', {
modifier: '&&&',
});
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import styled from 'styled-components';
import { withCustomCss } from 'utils/withCustomCss';
import { customCss } from 'utils/customCss';
import { StyledCssProps } from 'components/Components.styled.types';

type Props = StyledCssProps;

export const StyledSectionChild = withCustomCss(styled.div<Props>`
export const StyledSectionChild = styled.div<Props>`
padding-top: 2rem;
padding-bottom: 2rem;
`);
${(props) => customCss(props)}
`;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { SectionChild } from '.';
import 'jest-styled-components';

describe('SectionChild', () => {
it('should render', () => {
Expand All @@ -13,9 +14,11 @@ describe('SectionChild', () => {
expect(sectionChild).toHaveClass('foo');
});
it('should render custom CSS as class', () => {
render(<SectionChild customCss="customCss" />);
render(<SectionChild customCss="color: violet" />);
const sectionChild = screen.getByTestId('sectionChild');
expect(sectionChild).toHaveClass('custom');
expect(sectionChild).toHaveStyleRule('color', 'violet', {
modifier: '&&&',
});
});
it('should render children', () => {
render(<SectionChild>Children</SectionChild>);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Asset } from './Asset';
import { Asset } from '.';
import { ContentType } from './Asset.types';

describe('Asset', () => {
it('should render an image asset type', () => {
Expand All @@ -12,7 +13,7 @@ describe('Asset', () => {
screen.getByTestId('video');
});

const givenComponentRendered = (type: Asset.ContentType) =>
const givenComponentRendered = (type: ContentType) =>
render(
<Asset
asset={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { Video } from 'components/primitives/Video';
import { Image } from 'components/primitives/Image';
import { Props, ContentType } from './Asset.types';
import { Props, Type, ContentType } from './Asset.types';

export const Asset = ({
export const Asset: Type = ({
autoPlay,
controls,
className,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FunctionComponent } from 'react';
import { BaseProps } from 'components/Components.types';

export type Props = BaseProps & {
Expand All @@ -7,6 +8,10 @@ export type Props = BaseProps & {
controls?: boolean;
};

export type Type = FunctionComponent<Props> & {
ContentType?: typeof ContentType;
};

export enum ContentType {
Image = 'image',
Video = 'video',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components';
import { getTheme } from 'utils/getTheme';
import { Typography } from 'components/primitives/Typography';
import { withCustomCss } from 'utils/withCustomCss';
import { customCss } from 'utils/customCss';
import {
StyledBaseProps,
StyledCssProps,
Expand Down Expand Up @@ -46,7 +46,7 @@ export const StyledTypography = styled(Typography)`
padding: 0.15rem;
`;

export const StyledHighlighter = withCustomCss(styled.div<Props>`
export const StyledHighlighter = styled.div<Props>`
display: flex;
align-items: center;
justify-content: center;
Expand All @@ -70,4 +70,5 @@ export const StyledHighlighter = withCustomCss(styled.div<Props>`
width: 4rem;
height: 4rem;
}
`);
${(props) => customCss(props)}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Conversations = () => (
<ConversationList
conversations={[
{
id: 1,
id: '1',
title: 'Pau Teruel',
description: 'Description',
message: 'Message',
Expand All @@ -35,7 +35,7 @@ export const Conversations = () => (
unreadMessages: 0,
},
{
id: 2,
id: '2',
title: 'John Cena',
description: 'Description',
message: 'Message',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ConversationList } from '.';

describe('ConversationList', () => {
const testId = 'conversationList';
it('should render classname', () => {
it('should render class name', () => {
render(<ConversationList className="foo" conversations={[]} />);
const conversationList = screen.getByTestId(testId);
expect(conversationList).toHaveClass('foo');
Expand All @@ -27,7 +27,6 @@ describe('ConversationList', () => {
title: 'title',
description: 'description',
message: 'message',
messageClassName: 'italic',
time: 'time',
avatarText: 'avatarText',
isHighlighted: false,
Expand All @@ -41,7 +40,6 @@ describe('ConversationList', () => {
title: 'title',
description: 'description',
message: 'message',
messageClassName: 'italic',
time: 'time',
avatarText: 'avatarText',
isHighlighted: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getTheme } from 'utils/getTheme';
import { Typography } from 'components/primitives/Typography';
import { Props as TypographyProps } from 'components/primitives/Typography/Typography.types';
import { Icon } from 'components/primitives/Icon';
import { withCustomCss } from 'utils/withCustomCss';
import { customCss } from 'utils/customCss';
import {
StyledBaseProps,
StyledCssProps,
Expand Down Expand Up @@ -71,9 +71,7 @@ export const StyledProfileDescription = styled(Typography)`
${truncate}
`;

export const StyledProfileMessage = withCustomCss<
Props & TypographyProps
>(styled(Typography)`
export const StyledProfileMessage = styled(Typography)<StyledCssProps>`
margin-top: 0rem;
margin-bottom: 0rem;
${truncate}
Expand All @@ -82,7 +80,9 @@ export const StyledProfileMessage = withCustomCss<
&.error {
color: ${(props) => getTheme(props).colors.fillSystemError};
}
`);
${(props) => customCss(props)}
`;

export const StyledNotificationContainer = styled.div`
display: flex;
Expand Down
Loading

0 comments on commit a673b33

Please sign in to comment.