diff --git a/config/watcher.ts b/config/watcher.ts index 1235e0e9c..5e4938a90 100644 --- a/config/watcher.ts +++ b/config/watcher.ts @@ -4,6 +4,8 @@ import { Config, LongRunningExecutor, } from "../scripts/watcher"; +// Ensure environment variables are read. +import "./env"; const config: Config = { rootDir: path.resolve(__dirname, "../src"), @@ -42,9 +44,7 @@ const config: Config = { }, runDocz: { paths: [], - executor: new LongRunningExecutor( - "NODE_ENV=development npm run docz -- dev" - ), + executor: new LongRunningExecutor("npm run docz -- dev"), }, }, defaultSet: "client", diff --git a/src/core/client/stream/components/Comment/__snapshots__/TopBar.spec.tsx.snap b/src/core/client/stream/components/Comment/__snapshots__/TopBar.spec.tsx.snap index 9253404bd..02f3c7726 100644 --- a/src/core/client/stream/components/Comment/__snapshots__/TopBar.spec.tsx.snap +++ b/src/core/client/stream/components/Comment/__snapshots__/TopBar.spec.tsx.snap @@ -2,7 +2,7 @@ exports[`renders correctly on big screens 1`] = `
Hello World diff --git a/src/core/client/stream/components/Comment/__snapshots__/Username.spec.tsx.snap b/src/core/client/stream/components/Comment/__snapshots__/Username.spec.tsx.snap index ab0e141e6..54224f9b0 100644 --- a/src/core/client/stream/components/Comment/__snapshots__/Username.spec.tsx.snap +++ b/src/core/client/stream/components/Comment/__snapshots__/Username.spec.tsx.snap @@ -2,7 +2,7 @@ exports[`renders correctly on big screens 1`] = ` Marvin @@ -10,7 +10,7 @@ exports[`renders correctly on big screens 1`] = ` exports[`renders correctly on small screens 1`] = ` Marvin diff --git a/src/core/client/stream/components/Indent.css b/src/core/client/stream/components/Indent.css index c675b03a6..d779d93e0 100644 --- a/src/core/client/stream/components/Indent.css +++ b/src/core/client/stream/components/Indent.css @@ -4,5 +4,5 @@ } .level0 { - border-color: var(--palette-secondary-darkest); + border-color: var(--palette-grey-darkest); } diff --git a/src/core/client/stream/components/PostCommentForm.css b/src/core/client/stream/components/PostCommentForm.css index df045285d..7e3ef2e15 100644 --- a/src/core/client/stream/components/PostCommentForm.css +++ b/src/core/client/stream/components/PostCommentForm.css @@ -1,5 +1,5 @@ .textarea { - composes: body1 from "talk-ui/shared/typography.css"; + composes: bodyCopy from "talk-ui/shared/typography.css"; display: block; height: 100px; diff --git a/src/core/client/stream/components/PostCommentForm.tsx b/src/core/client/stream/components/PostCommentForm.tsx index 09db70e39..badcbaca8 100644 --- a/src/core/client/stream/components/PostCommentForm.tsx +++ b/src/core/client/stream/components/PostCommentForm.tsx @@ -41,7 +41,7 @@ const PostCommentForm: StatelessComponent = props => (
- diff --git a/src/core/client/stream/components/ReplyList.tsx b/src/core/client/stream/components/ReplyList.tsx index 17ad32ed2..6f4380769 100644 --- a/src/core/client/stream/components/ReplyList.tsx +++ b/src/core/client/stream/components/ReplyList.tsx @@ -34,8 +34,7 @@ const ReplyList: StatelessComponent = props => { aria-controls={`talk-comments-replyList-log--${props.commentID}`} onClick={props.onShowAll} disabled={props.disableShowAll} - secondary - invert + variant="outlined" fullWidth > Show All Replies diff --git a/src/core/client/stream/components/Stream.tsx b/src/core/client/stream/components/Stream.tsx index da55050f5..9dbb21c5b 100644 --- a/src/core/client/stream/components/Stream.tsx +++ b/src/core/client/stream/components/Stream.tsx @@ -42,8 +42,7 @@ const Stream: StatelessComponent = props => {

Joining Too

@@ -86,7 +86,7 @@ exports[`loads more comments 1`] = ` className="Flex-root TopBar-root Flex-halfItemGutter Flex-alignBaseline Flex-directionColumn" > Lukas @@ -99,7 +99,7 @@ exports[`loads more comments 1`] = `

What's up?

@@ -115,7 +115,7 @@ exports[`loads more comments 1`] = ` className="Flex-root TopBar-root Flex-halfItemGutter Flex-alignBaseline Flex-directionColumn" > Isabelle @@ -128,7 +128,7 @@ exports[`loads more comments 1`] = `

Hey!

@@ -141,13 +141,13 @@ exports[`loads more comments 1`] = ` exports[`renders comment stream 1`] = `

Talk NEO

@@ -167,7 +167,7 @@ exports[`renders comment stream 1`] = ` className="PostCommentForm-postButtonContainer" >

Joining Too

@@ -225,7 +225,7 @@ exports[`renders comment stream 1`] = ` className="Flex-root TopBar-root Flex-halfItemGutter Flex-alignBaseline Flex-directionColumn" > Lukas @@ -238,7 +238,7 @@ exports[`renders comment stream 1`] = `

What's up?

@@ -246,7 +246,7 @@ exports[`renders comment stream 1`] = ` + + + + + - - - - - - - - - - - + + + - -## Button with Icon +## Filled Button - - - - + + + + + + + + + + + +## Outlined Button + + + + + + + + + + + + + + +## Ghost Button + + + + + + + + + + + + + + diff --git a/src/core/client/ui/components/Button/Button.spec.tsx b/src/core/client/ui/components/Button/Button.spec.tsx new file mode 100644 index 000000000..98ddf9ca0 --- /dev/null +++ b/src/core/client/ui/components/Button/Button.spec.tsx @@ -0,0 +1,62 @@ +import React from "react"; +import ShallowRenderer from "react-test-renderer/shallow"; + +import { PropTypesOf } from "talk-framework/types"; + +import { Button } from "./Button"; + +it("renders correctly", () => { + const props: PropTypesOf = { + classes: { + mouseHover: "mouseHover", + keyboardFocus: "keyboardFocus", + } as any, + children: "Push me", + }; + const renderer = ShallowRenderer.createRenderer(); + renderer.render( + + + + + +## Direction + + + + + + + diff --git a/src/core/client/ui/components/Flex/Flex.tsx b/src/core/client/ui/components/Flex/Flex.tsx index 62d8ff66c..240e13f9e 100644 --- a/src/core/client/ui/components/Flex/Flex.tsx +++ b/src/core/client/ui/components/Flex/Flex.tsx @@ -4,6 +4,7 @@ import { StatelessComponent } from "react"; import { pascalCase } from "talk-common/utils"; import { withForwardRef, withStyles } from "talk-ui/hocs"; +import { PropTypesOf } from "talk-ui/types"; import * as styles from "./Flex.css"; @@ -28,9 +29,6 @@ interface InnerProps { className?: string; wrap?: boolean | "reverse"; - /** Ref to the root element */ - ref?: Ref; - /** Internal: Forwarded Ref */ forwardRef?: Ref; } @@ -48,6 +46,11 @@ const Flex: StatelessComponent = props => { ...rest } = props; + let alignItemsWithDefault = alignItems; + if (!direction || !direction.startsWith("column")) { + alignItemsWithDefault = "center"; + } + const classObject: Record = { [classes.itemGutter]: itemGutter === true, [classes.halfItemGutter]: itemGutter === "half", @@ -61,8 +64,10 @@ const Flex: StatelessComponent = props => { ] = true; } - if (alignItems) { - classObject[(classes as any)[`align${pascalCase(alignItems)}`]] = true; + if (alignItemsWithDefault) { + classObject[ + (classes as any)[`align${pascalCase(alignItemsWithDefault)}`] + ] = true; } if (direction) { @@ -74,4 +79,6 @@ const Flex: StatelessComponent = props => { return
; }; -export default withForwardRef(withStyles(styles)(Flex)); +const enhanced = withForwardRef(withStyles(styles)(Flex)); +export default enhanced; +export type FlexProps = PropTypesOf; diff --git a/src/core/client/ui/components/Flex/__snapshots__/Flex.spec.tsx.snap b/src/core/client/ui/components/Flex/__snapshots__/Flex.spec.tsx.snap index 31f1f73c1..e6530fe18 100644 --- a/src/core/client/ui/components/Flex/__snapshots__/Flex.spec.tsx.snap +++ b/src/core/client/ui/components/Flex/__snapshots__/Flex.spec.tsx.snap @@ -12,7 +12,7 @@ exports[`renders correctly 1`] = ` exports[`renders with halfe item gutter 1`] = `
Hello World @@ -22,7 +22,7 @@ exports[`renders with halfe item gutter 1`] = ` exports[`renders with item gutter 1`] = `
Hello World @@ -32,7 +32,7 @@ exports[`renders with item gutter 1`] = ` exports[`renders with wrap 1`] = `
Hello World @@ -42,7 +42,7 @@ exports[`renders with wrap 1`] = ` exports[`renders with wrap reverse 1`] = `
Hello World diff --git a/src/core/client/ui/components/Flex/index.ts b/src/core/client/ui/components/Flex/index.ts index 27e09f37b..434836f6d 100644 --- a/src/core/client/ui/components/Flex/index.ts +++ b/src/core/client/ui/components/Flex/index.ts @@ -1,2 +1 @@ -export * from "./Flex"; -export { default } from "./Flex"; +export { default, FlexProps } from "./Flex"; diff --git a/src/core/client/ui/components/Icon/Icon.tsx b/src/core/client/ui/components/Icon/Icon.tsx index 754a46955..3b8889fa1 100644 --- a/src/core/client/ui/components/Icon/Icon.tsx +++ b/src/core/client/ui/components/Icon/Icon.tsx @@ -18,9 +18,6 @@ interface InnerProps extends HTMLAttributes { /** The name of the icon to render */ children: string; - /** ref to the HTMLIconElement */ - ref?: Ref; - /** Internal: Forwarded Ref */ forwardRef?: Ref; } diff --git a/src/core/client/ui/components/Icon/index.ts b/src/core/client/ui/components/Icon/index.ts index 3e8146f8b..d3ba5da55 100644 --- a/src/core/client/ui/components/Icon/index.ts +++ b/src/core/client/ui/components/Icon/index.ts @@ -1,2 +1 @@ -export * from "./Icon"; -export { default } from "./Icon"; +export { default, IconProps } from "./Icon"; diff --git a/src/core/client/ui/components/MatchMedia/MatchMedia.tsx b/src/core/client/ui/components/MatchMedia/MatchMedia.tsx index 43d900dfe..8df6cff34 100644 --- a/src/core/client/ui/components/MatchMedia/MatchMedia.tsx +++ b/src/core/client/ui/components/MatchMedia/MatchMedia.tsx @@ -2,6 +2,8 @@ import React from "react"; import { ReactNode, StatelessComponent } from "react"; import Responsive, { MediaQueryMatchers } from "react-responsive"; +import { PropTypesOf } from "talk-ui/types"; + import theme from "../../theme/variables"; import UIContext from "../UIContext"; @@ -45,3 +47,4 @@ const MatchMediaWithContext: StatelessComponent = props => ( ); export default MatchMediaWithContext; +export type MatchMediaProps = PropTypesOf; diff --git a/src/core/client/ui/components/MatchMedia/index.ts b/src/core/client/ui/components/MatchMedia/index.ts index 71f16f6f8..66da09460 100644 --- a/src/core/client/ui/components/MatchMedia/index.ts +++ b/src/core/client/ui/components/MatchMedia/index.ts @@ -1,2 +1 @@ -export * from "./MatchMedia"; -export { default } from "./MatchMedia"; +export { default, MatchMediaProps } from "./MatchMedia"; diff --git a/src/core/client/ui/components/RelativeTime/RelativeTime.css b/src/core/client/ui/components/RelativeTime/RelativeTime.css index 3faa5e162..e0450679f 100644 --- a/src/core/client/ui/components/RelativeTime/RelativeTime.css +++ b/src/core/client/ui/components/RelativeTime/RelativeTime.css @@ -1,4 +1,4 @@ .root { - composes: body1 from "talk-ui/shared/typography.css"; + composes: bodyCopy from "talk-ui/shared/typography.css"; background-color: transparent; } diff --git a/src/core/client/ui/components/RelativeTime/RelativeTime.tsx b/src/core/client/ui/components/RelativeTime/RelativeTime.tsx index 136bbca4f..265a64978 100644 --- a/src/core/client/ui/components/RelativeTime/RelativeTime.tsx +++ b/src/core/client/ui/components/RelativeTime/RelativeTime.tsx @@ -15,9 +15,6 @@ interface InnerProps { className?: string; formatter?: Formatter; - /** Ref to the root element */ - ref?: Ref; - /** Internal: Forwarded Ref */ forwardRef?: Ref; } diff --git a/src/core/client/ui/components/RelativeTime/index.ts b/src/core/client/ui/components/RelativeTime/index.ts index 8bc2dfb5e..90bd4c0ca 100644 --- a/src/core/client/ui/components/RelativeTime/index.ts +++ b/src/core/client/ui/components/RelativeTime/index.ts @@ -1,2 +1 @@ -export * from "./RelativeTime"; -export { default } from "./RelativeTime"; +export { default, RelativeTimeProps } from "./RelativeTime"; diff --git a/src/core/client/ui/components/TrapFocus/index.ts b/src/core/client/ui/components/TrapFocus/index.ts index 965ecf53a..2bb55f23d 100644 --- a/src/core/client/ui/components/TrapFocus/index.ts +++ b/src/core/client/ui/components/TrapFocus/index.ts @@ -1,2 +1 @@ -export * from "./TrapFocus"; -export { default } from "./TrapFocus"; +export { default, TrapFocusProps } from "./TrapFocus"; diff --git a/src/core/client/ui/components/Typography/Typography.css b/src/core/client/ui/components/Typography/Typography.css index a3c19a400..8b0edc3b8 100644 --- a/src/core/client/ui/components/Typography/Typography.css +++ b/src/core/client/ui/components/Typography/Typography.css @@ -19,28 +19,16 @@ composes: heading4 from "talk-ui/shared/typography.css"; } -.subtitle1 { - composes: subtitle1 from "talk-ui/shared/typography.css"; -} - -.subtitle2 { - composes: subtitle2 from "talk-ui/shared/typography.css"; -} - -.body1 { - composes: body1 from "talk-ui/shared/typography.css"; -} - -.body2 { - composes: body2 from "talk-ui/shared/typography.css"; +.bodyCopy { + composes: bodyCopy from "talk-ui/shared/typography.css"; } .button { composes: button from "talk-ui/shared/typography.css"; } -.overline { - composes: overline from "talk-ui/shared/typography.css"; +.buttonLarge { + composes: buttonLarge from "talk-ui/shared/typography.css"; } .timestamp { @@ -85,8 +73,8 @@ color: var(--palette-primary-main); } -.colorSecondary { - color: var(--palette-secondary-main); +.colorTextPrimary { + color: var(--palette-text-primary); } .colorTextSecondary { @@ -96,3 +84,7 @@ .colorError { color: var(--palette-error-main); } + +.colorSuccess { + color: var(--palette-success-main); +} diff --git a/src/core/client/ui/components/Typography/Typography.mdx b/src/core/client/ui/components/Typography/Typography.mdx new file mode 100644 index 000000000..8833e95f9 --- /dev/null +++ b/src/core/client/ui/components/Typography/Typography.mdx @@ -0,0 +1,56 @@ +--- +name: Typography +menu: UI Kit +--- + +import { Playground } from 'docz' +import Typography from './Typography' +import Flex from '../Flex' + +# Typography + +## Basic Use + + + Heading1 + Heading2 + Heading3 + Heading4 + BodyCopy + timestamp + + + +## Using different colors + + + textPrimary + textSecondary + success + error + + + +## Set align + + + left + center + right + No hay nadie que ame el dolor mismo, que lo busque, lo encuentre y lo + quiera, simplemente porque es el dolor. + + + +## Cut off long text + + No hay nadie que ame el dolor mismo, que lo busque, lo encuentre y lo quiera, simplemente porque es el dolor. + + +## Gutters + + I have a bottom gutter + I have a paragraph gutter + Just a normal text + + diff --git a/src/core/client/ui/components/Typography/Typography.spec.tsx b/src/core/client/ui/components/Typography/Typography.spec.tsx new file mode 100644 index 000000000..d694869f8 --- /dev/null +++ b/src/core/client/ui/components/Typography/Typography.spec.tsx @@ -0,0 +1,20 @@ +import React from "react"; +import TestRenderer from "react-test-renderer"; + +import { PropTypesOf } from "talk-ui/types"; + +import Typography from "./Typography"; + +it("renders correctly", () => { + const props: PropTypesOf = { + className: "custom", + variant: "heading1", + color: "textSecondary", + gutterBottom: true, + children: "Hello World", + noWrap: true, + align: "left", + }; + const renderer = TestRenderer.create(); + expect(renderer.toJSON()).toMatchSnapshot(); +}); diff --git a/src/core/client/ui/components/Typography/Typography.tsx b/src/core/client/ui/components/Typography/Typography.tsx index b78347944..752f1f828 100644 --- a/src/core/client/ui/components/Typography/Typography.tsx +++ b/src/core/client/ui/components/Typography/Typography.tsx @@ -12,11 +12,7 @@ type Variant = | "heading2" | "heading3" | "heading4" - | "subtitle1" - | "subtitle2" - | "body1" - | "body2" - | "button" + | "bodyCopy" | "timestamp"; // Based on Typography Component of Material UI. @@ -45,10 +41,10 @@ interface InnerProps extends HTMLAttributes { color?: | "inherit" | "primary" + | "textPrimary" | "textSecondary" - | "secondary" | "error" - | "default"; + | "success"; /** * The component used for the root node. * Either a string to use a DOM element or a component. @@ -78,9 +74,6 @@ interface InnerProps extends HTMLAttributes { */ variant?: Variant; - /** Ref to the root element */ - ref?: Ref; - /** Internal: Forwarded Ref */ forwardRef?: Ref; } @@ -105,10 +98,11 @@ const Typography: StatelessComponent = props => { classes.root, classes[variant!], { - [classes.colorPrimary]: color === "primary", - [classes.colorSecondary]: color === "secondary", - [classes.colorError]: color === "error", + [classes.colorTextPrimary]: color === "textPrimary", [classes.colorTextSecondary]: color === "textSecondary", + [classes.colorPrimary]: color === "primary", + [classes.colorError]: color === "error", + [classes.colorSuccess]: color === "success", [classes.noWrap]: noWrap, [classes.gutterBottom]: gutterBottom, [classes.paragraph]: paragraph, @@ -128,24 +122,21 @@ const Typography: StatelessComponent = props => { Typography.defaultProps = { align: "inherit", - color: "default", + color: "textPrimary", gutterBottom: false, headlineMapping: { heading1: "h1", heading2: "h1", heading3: "h1", heading4: "h1", - subtitle1: "h2", - subtitle2: "h3", - body1: "p", - body2: "aside", + bodyCopy: "p", timestamp: "span", }, noWrap: false, paragraph: false, - variant: "body1", + variant: "bodyCopy", }; const enhanced = withForwardRef(withStyles(styles)(Typography)); -export type CenterProps = PropTypesOf; +export type TypographyProps = PropTypesOf; export default enhanced; diff --git a/src/core/client/ui/components/Typography/__snapshots__/Typography.spec.tsx.snap b/src/core/client/ui/components/Typography/__snapshots__/Typography.spec.tsx.snap new file mode 100644 index 000000000..66abdab95 --- /dev/null +++ b/src/core/client/ui/components/Typography/__snapshots__/Typography.spec.tsx.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` +

+ Hello World +

+`; diff --git a/src/core/client/ui/components/Typography/index.ts b/src/core/client/ui/components/Typography/index.ts index 1557f9552..45ed99c30 100644 --- a/src/core/client/ui/components/Typography/index.ts +++ b/src/core/client/ui/components/Typography/index.ts @@ -1,2 +1 @@ -export * from "./Typography"; -export { default } from "./Typography"; +export { default, TypographyProps } from "./Typography"; diff --git a/src/core/client/ui/shared/typography.css b/src/core/client/ui/shared/typography.css index edc334b96..9e52cfc89 100644 --- a/src/core/client/ui/shared/typography.css +++ b/src/core/client/ui/shared/typography.css @@ -91,16 +91,7 @@ color: var(--palette-text-primary); } -.subtitle1 { -} - -.subtitle2 { -} - -.body2 { -} - -.body1 { +.bodyCopy { font-size: calc(16rem / var(--rem-base)); font-weight: var(--font-weight-regular); font-family: "Source Sans Pro"; @@ -113,11 +104,18 @@ color: var(--palette-text-secondary); font-family: "Source Sans Pro"; font-weight: var(--font-weight-medium); - font-size: 16px; + font-size: 14px; + line-height: calc(18em / 16); letter-spacing: calc(0.57em / 16); } -.overline { +.buttonLarge { + color: var(--palette-text-secondary); + font-family: "Source Sans Pro"; + font-weight: var(--font-weight-medium); + font-size: 16px; + line-height: calc(20em / 16); + letter-spacing: calc(0.57em / 16); } .timestamp { diff --git a/src/core/client/ui/theme/variables.ts b/src/core/client/ui/theme/variables.ts index 6e404f10f..415a5c32f 100644 --- a/src/core/client/ui/theme/variables.ts +++ b/src/core/client/ui/theme/variables.ts @@ -12,14 +12,16 @@ const variables = { main: "#3498DB", light: "#67B2E4", lighter: "#8DC5EB", + lightest: "#EBF5FB", }, /* Secondary colors */ - secondary: { + grey: { darkest: "#404345", dark: "#65696B", main: "#787D80", light: "#9A9DA0", lighter: "#BBBEBF", + lightest: "#F5F5F5", }, /* Success colors */ success: { @@ -28,21 +30,21 @@ const variables = { main: "#00CD73", light: "#40D996", lighter: "#83EBBD", + lightest: "#E6FAF1", }, /* Error colors */ error: { darkest: "#F50F0C", dark: "#FF1F1C", main: "#FA4643", - light: "#F26563", - lighter: "#F26563", + light: "#FB7472", + lighter: "#FC9795", + lightest: "#FEF0EF", }, /* Text colors */ text: { primary: "#3B4A53", secondary: "#787D80", - disabled: "rgba(0, 0, 0, 0.38)", - hint: "rgba(0, 0, 0, 0.38)", }, /* Common colors */ common: { @@ -51,11 +53,6 @@ const variables = { }, /* Divider */ divider: "rgba(0, 0, 0, 0.12)", - /* The background colors used to style the surfaces. */ - background: { - paper: "#FFF", - default: "#FAFAFA", - }, }, /* gitter and spacing */ spacingUnitSmall: 5,