Skip to content

Commit

Permalink
FIX emotion SSR warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Apr 22, 2020
1 parent d78d235 commit 2111919
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
@@ -1,7 +1,9 @@
import React from 'react';
import { DocgenButton } from '../../components/DocgenButton';

const ForwardedButton = React.forwardRef((props, ref) => <DocgenButton ref={ref} {...props} />);
const ForwardedButton = React.forwardRef((props = { label: '' }, ref) => (
<DocgenButton ref={ref} {...props} />
));

export default {
title: 'Addons|Docs/ForwardRef',
Expand Down
16 changes: 8 additions & 8 deletions lib/components/src/blocks/ArgsTable/ArgsTable.tsx
@@ -1,5 +1,5 @@
import React, { FC } from 'react';
import { styled } from '@storybook/theming';
import { styled, ignoreSsrWarning } from '@storybook/theming';
import { opacify, transparentize, darken, lighten } from 'polished';
import { ArgRow, ArgRowProps } from './ArgRow';
import { SectionRow, SectionRowProps } from './SectionRow';
Expand Down Expand Up @@ -79,20 +79,20 @@ export const TableWrapper = styled.table<{}>(({ theme }) => ({
marginLeft: 1,
marginRight: 1,

'tr:first-child': {
'td:first-child, th:first-child': {
[`tr:first-child${ignoreSsrWarning}`]: {
[`td:first-child${ignoreSsrWarning}, th:first-child${ignoreSsrWarning}`]: {
borderTopLeftRadius: theme.appBorderRadius,
},
'td:last-child, th:last-child': {
[`td:last-child${ignoreSsrWarning}, th:last-child${ignoreSsrWarning}`]: {
borderTopRightRadius: theme.appBorderRadius,
},
},

'tr:last-child': {
'td:first-child, th:first-child': {
[`tr:last-child${ignoreSsrWarning}`]: {
[`td:first-child${ignoreSsrWarning}, th:first-child${ignoreSsrWarning}`]: {
borderBottomLeftRadius: theme.appBorderRadius,
},
'td:last-child, th:last-child': {
[`td:last-child${ignoreSsrWarning}, th:last-child${ignoreSsrWarning}`]: {
borderBottomRightRadius: theme.appBorderRadius,
},
},
Expand All @@ -110,7 +110,7 @@ export const TableWrapper = styled.table<{}>(({ theme }) => ({
tr: {
background: 'transparent',
overflow: 'hidden',
'&:not(:first-child)': {
[`&:not(:first-child${ignoreSsrWarning})`]: {
borderTopWidth: 1,
borderTopStyle: 'solid',
borderTopColor:
Expand Down
14 changes: 7 additions & 7 deletions lib/components/src/blocks/PropsTable/PropsTable.tsx
@@ -1,5 +1,5 @@
import React, { FC } from 'react';
import { styled } from '@storybook/theming';
import { styled, ignoreSsrWarning } from '@storybook/theming';
import { opacify, transparentize, darken, lighten } from 'polished';
import { PropRow, PropRowProps } from './PropRow';
import { SectionRow, SectionRowProps } from './SectionRow';
Expand Down Expand Up @@ -79,20 +79,20 @@ export const Table = styled.table<{}>(({ theme }) => ({
marginLeft: 1,
marginRight: 1,

'tr:first-child': {
'td:first-child, th:first-child': {
[`tr:first-child${ignoreSsrWarning}`]: {
[`td:first-child${ignoreSsrWarning}, th:first-child${ignoreSsrWarning}`]: {
borderTopLeftRadius: theme.appBorderRadius,
},
'td:last-child, th:last-child': {
[`td:last-child${ignoreSsrWarning}, th:last-child${ignoreSsrWarning}`]: {
borderTopRightRadius: theme.appBorderRadius,
},
},

'tr:last-child': {
'td:first-child, th:first-child': {
[`tr:last-child${ignoreSsrWarning}`]: {
[`td:first-child${ignoreSsrWarning}, th:first-child${ignoreSsrWarning}`]: {
borderBottomLeftRadius: theme.appBorderRadius,
},
'td:last-child, th:last-child': {
[`td:last-child${ignoreSsrWarning}, th:last-child${ignoreSsrWarning}`]: {
borderBottomRightRadius: theme.appBorderRadius,
},
},
Expand Down
5 changes: 1 addition & 4 deletions lib/components/src/spaced/Spaced.tsx
@@ -1,11 +1,8 @@
import React, { FunctionComponent } from 'react';
import { styled } from '@storybook/theming';
import { styled, ignoreSsrWarning } from '@storybook/theming';

const toNumber = (input: any) => (typeof input === 'number' ? input : Number(input));

const ignoreSsrWarning =
'/* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */';

export interface ContainerProps {
col?: number;
row?: number;
Expand Down
3 changes: 3 additions & 0 deletions lib/theming/src/index.ts
Expand Up @@ -16,3 +16,6 @@ export * from './convert';
export * from './ensure';

export { lightenColor as lighten, darkenColor as darken } from './utils';

export const ignoreSsrWarning =
'/* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */';

0 comments on commit 2111919

Please sign in to comment.