Skip to content

Commit

Permalink
fix: style fixes, add docs SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
LexSwed committed Oct 4, 2020
1 parent 4fd1009 commit 06dfcec
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/lib/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Icon from '../Icon';
const ButtonRoot = styled(Stack, {
'px': '$3',
'fontSize': '$sm',
'display': 'inline-flex',
'height': '$base',
'lineHeight': '$base',
'fontWeight': 500,
Expand Down Expand Up @@ -126,7 +125,17 @@ const Button = React.forwardRef<HTMLButtonElement, Props>(
const ref = useForkRef(innerRef, propRef);

return (
<ButtonRoot {...buttonProps} flow="row" css={css} space="$2" variant={variant} as={as} ref={ref}>
<ButtonRoot
{...buttonProps}
flow="row"
alignY="center"
display="inline"
css={css}
space="$2"
variant={variant}
as={as}
ref={ref}
>
{props.children}
</ButtonRoot>
);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Label/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Props = React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>

const Label: React.FC<Props> = ({ label, children: _ignore, secondary, ref, ...props }) => {
return (
<Wrapper {...props} flow="row" space="xs" display="inline" as="label" ref={ref as any}>
<Wrapper {...props} flow="row" alignY="center" space="xs" display="inline" as="label" ref={ref as any}>
<Main>{label}</Main>
{secondary && <Secondary>{secondary}</Secondary>}
</Wrapper>
Expand Down
2 changes: 2 additions & 0 deletions src/lib/Menu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ const MenuItem = React.forwardRef<HTMLLIElement, Props>(({ action, ...props }, r
as="li"
{...props}
flow="row"
alignY="center"
display="inline"
onClick={onClick}
tabIndex={props.disabled ? undefined : -1}
role="menuitem"
Expand Down
46 changes: 46 additions & 0 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import NextDocument, { DocumentContext, Head, Html, Main, NextScript } from 'next/document';
import { css } from 'src/lib/stitches.config';

export default class Document extends NextDocument {
static async getInitialProps(ctx: DocumentContext) {
const originalRenderPage = ctx.renderPage;

try {
let extractedStyles: any[] = [];
ctx.renderPage = () => {
const { styles, result } = css.getStyles(originalRenderPage);
extractedStyles = styles;
return result;
};

const initialProps = await NextDocument.getInitialProps(ctx);

return {
...initialProps,
styles: (
<>
{initialProps.styles}

{extractedStyles.map((content, index) => (
<style key={index} dangerouslySetInnerHTML={{ __html: content }} />
))}
</>
),
};
} finally {
}
}

render() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}

0 comments on commit 06dfcec

Please sign in to comment.