From 393813ce4e142a288b87353c6849daebebaedbfb Mon Sep 17 00:00:00 2001 From: muerwre Date: Thu, 1 Aug 2019 19:11:01 +0700 Subject: [PATCH] fixed features at editor --- src/components/containers/Grid/index.tsx | 41 ++++--- src/components/containers/Grid/styles.scss | 4 + src/components/input/Button/index.tsx | 78 ++++++------- src/components/input/Button/styles.scss | 62 +++++++--- src/components/input/Icon/index.tsx | 12 +- src/components/main/Header/index.tsx | 47 +++++--- .../examples/EditorExample/index.tsx | 108 ++++++++---------- .../examples/EditorExample/styles.scss | 12 +- src/sprites/Sprites.tsx | 3 +- 9 files changed, 204 insertions(+), 163 deletions(-) diff --git a/src/components/containers/Grid/index.tsx b/src/components/containers/Grid/index.tsx index cc20a109..a7f6d9a9 100644 --- a/src/components/containers/Grid/index.tsx +++ b/src/components/containers/Grid/index.tsx @@ -1,6 +1,6 @@ -import React, { FC } from 'react'; -import classNames from 'classnames'; -import * as styles from './styles.scss'; +import React, { FC } from "react"; +import classNames from "classnames"; +import * as styles from "./styles.scss"; type IProps = React.HTMLAttributes & { horizontal?: boolean; @@ -10,39 +10,42 @@ type IProps = React.HTMLAttributes & { size?: string; square?: boolean; gap?: number; + stretchy?: boolean; }; const Grid: FC = ({ children, - className = '', + className = "", horizontal = false, vertical = false, square = false, - size = 'auto', + size = "auto", style = {}, - columns = 'auto', - rows = 'auto', + columns = "auto", + rows = "auto", gap = 10, + stretchy, ...props }) => (
diff --git a/src/components/containers/Grid/styles.scss b/src/components/containers/Grid/styles.scss index 45fd131e..a47fa7e3 100644 --- a/src/components/containers/Grid/styles.scss +++ b/src/components/containers/Grid/styles.scss @@ -15,4 +15,8 @@ &.square { grid-auto-flow: dense; } + + &.stretchy { + flex: 1; + } } diff --git a/src/components/input/Button/index.tsx b/src/components/input/Button/index.tsx index 9309b9d5..f4b70626 100644 --- a/src/components/input/Button/index.tsx +++ b/src/components/input/Button/index.tsx @@ -1,25 +1,29 @@ -import classnames from 'classnames'; -import * as styles from './styles.scss'; -import React, { ButtonHTMLAttributes, DetailedHTMLProps, FC } from 'react'; -import { Icon } from '~/components/input/Icon'; +import classnames from "classnames"; +import * as styles from "./styles.scss"; +import React, { ButtonHTMLAttributes, DetailedHTMLProps, FC } from "react"; +import { Icon } from "~/components/input/Icon"; import { IIcon } from "~/redux/types"; -type IButtonProps = DetailedHTMLProps, HTMLButtonElement> & { - size?: 'mini' | 'normal' | 'big' | 'giant' | 'micro'; +type IButtonProps = DetailedHTMLProps< + ButtonHTMLAttributes, + HTMLButtonElement +> & { + size?: "mini" | "normal" | "big" | "giant" | "micro"; iconLeft?: IIcon; iconRight?: IIcon; seamless?: boolean; transparent?: boolean; title?: string; - red?: boolean, - grey?: boolean, + red?: boolean; + grey?: boolean; non_submitting?: boolean; is_loading?: boolean; + stretchy?: boolean; }; export const Button: FC = ({ - className = '', - size = 'normal', + className = "", + size = "normal", iconLeft, iconRight, children, @@ -30,34 +34,28 @@ export const Button: FC = ({ grey = false, is_loading, title, + stretchy, ...props -}) => ( - React.createElement( - (seamless || non_submitting) ? 'div' : 'button', - { - className: classnames( - styles.button, - className, - styles[size], - { - red, - grey, - seamless, - transparent, - disabled: props.disabled, - icon: (iconLeft || iconRight) && !title && !children, - is_loading, - }), - children: [ - iconLeft && , - ( - title - ? {title} - : (children && {children}) || null - ), - iconRight && , - ], - ...props, - }, - ) -); +}) => + React.createElement(seamless || non_submitting ? "div" : "button", { + className: classnames(styles.button, className, styles[size], { + red, + grey, + seamless, + transparent, + disabled: props.disabled, + icon: (iconLeft || iconRight) && !title && !children, + is_loading, + stretchy + }), + children: [ + iconLeft && , + title ? ( + {title} + ) : ( + (children && {children}) || null + ), + iconRight && + ], + ...props + }); diff --git a/src/components/input/Button/styles.scss b/src/components/input/Button/styles.scss index 5116581d..e6e8b9c5 100644 --- a/src/components/input/Button/styles.scss +++ b/src/components/input/Button/styles.scss @@ -1,6 +1,10 @@ @keyframes pulse { - 0% { opacity: 1; } - 100% { opacity: 0.3; } + 0% { + opacity: 1; + } + 100% { + opacity: 0.3; + } } .button { @@ -28,23 +32,27 @@ justify-content: center; // box-shadow: transparentize(#E933A5, 0.6) 0 2px 8px; - box-shadow: transparentize(#E933A5, 0.6) 0 0 0; + box-shadow: transparentize(#e933a5, 0.6) 0 0 0; filter: grayscale(0); transition: opacity 0.25s, filter 0.25s, box-shadow 0.25s; opacity: 0.8; + span { + flex: 1; + } + &:hover { opacity: 1; - box-shadow: transparentize(#E933A5, 0.4) 0 2px 8px; + box-shadow: transparentize(#e933a5, 0.4) 0 2px 8px; &:global(.disabled) { - box-shadow: transparentize(#E933A5, 0.6) 0 0 0; + box-shadow: transparentize(#e933a5, 0.6) 0 0 0; cursor: auto; } &:active { - box-shadow: transparentize(#E933A5, 0.6) 0 0 0; + box-shadow: transparentize(#e933a5, 0.6) 0 0 0; } } @@ -72,7 +80,12 @@ color: $red; } - &:global(.disabled), &:global(.grey) { + &:global(.stretchy) { + flex: 1; + } + + &:global(.disabled), + &:global(.grey) { opacity: 0.3; //background: black; filter: grayscale(100%); @@ -84,7 +97,8 @@ } &:global(.is_loading) { - span, svg { + span, + svg { animation: pulse 0.25s infinite alternate; } } @@ -92,16 +106,34 @@ > * { margin: 0 5px; - &:first-child { margin-left: 0; } - &:last-child { margin-right: 0; } + &:first-child { + margin-left: 0; + } + &:last-child { + margin-right: 0; + } } } -.micro { height: 20px; font: $font_12_semibold; padding: 0 15px;} -.mini { height: 28px; } -.normal { height: 38px; } -.big { height: 40px; } -.giant { height: 50px; padding: 0 15px; min-width: 50px; } +.micro { + height: 20px; + font: $font_12_semibold; + padding: 0 15px; +} +.mini { + height: 28px; +} +.normal { + height: 38px; +} +.big { + height: 40px; +} +.giant { + height: 50px; + padding: 0 15px; + min-width: 50px; +} .disabled { opacity: 0.5; } diff --git a/src/components/input/Icon/index.tsx b/src/components/input/Icon/index.tsx index 01d52f8f..593490a3 100644 --- a/src/components/input/Icon/index.tsx +++ b/src/components/input/Icon/index.tsx @@ -1,23 +1,19 @@ -import React, { FC } from 'react'; -import { IIcon } from '~/redux/types'; +import React, { FC } from "react"; +import { IIcon } from "~/redux/types"; type IProps = React.SVGAttributes & { size?: number; icon: IIcon; }; -export const Icon: FC = ({ - size = 20, - icon, - ...props -}) => ( +export const Icon: FC = ({ size = 20, icon, style, ...props }) => ( diff --git a/src/components/main/Header/index.tsx b/src/components/main/Header/index.tsx index b45f1a2d..91a85299 100644 --- a/src/components/main/Header/index.tsx +++ b/src/components/main/Header/index.tsx @@ -1,28 +1,38 @@ -import * as React from 'react'; +import * as React from "react"; import { Logo } from "~/components/main/Logo"; -import { connect } from 'react-redux'; +import { connect } from "react-redux"; import { IUserState } from "~/redux/user/reducer"; -import { push as historyPush } from 'connected-react-router'; +import { push as historyPush } from "connected-react-router"; -import * as style from './style.scss'; -import {Filler} from "~/components/containers/Filler"; -import {Group} from "~/components/containers/Group"; -import { Link } from 'react-router-dom'; +import * as style from "./style.scss"; +import { Filler } from "~/components/containers/Filler"; +import { Link } from "react-router-dom"; + +const mapStateToProps = ({ + user: { + profile: { username, is_user } + } +}: { + user: IUserState; +}) => ({ username, is_user }); -const mapStateToProps = ({ user: { profile: { username, is_user } } }: { user: IUserState }) => ({ username, is_user }); const mapDispatchToProps = { - push: historyPush, + push: historyPush }; -type IHeaderProps = ReturnType & typeof mapDispatchToProps & {}; +type IHeaderProps = ReturnType & + typeof mapDispatchToProps & {}; -export const Component: React.FunctionComponent = ({ username, is_user }) => { +export const Component: React.FunctionComponent = ({ + username, + is_user +}) => { return (
- + - +
flow @@ -31,15 +41,18 @@ export const Component: React.FunctionComponent = ({ username, is_ horizontal
- + - + {/*
username
- + */}
); }; -export const Header = connect(mapStateToProps, mapDispatchToProps)(Component); +export const Header = connect( + mapStateToProps, + mapDispatchToProps +)(Component); diff --git a/src/containers/examples/EditorExample/index.tsx b/src/containers/examples/EditorExample/index.tsx index 5fb25f70..79508724 100644 --- a/src/containers/examples/EditorExample/index.tsx +++ b/src/containers/examples/EditorExample/index.tsx @@ -1,6 +1,6 @@ -import React, { FC } from 'react'; +import React, { FC } from "react"; import { Card } from "~/components/containers/Card"; -import * as styles from './styles.scss'; +import * as styles from "./styles.scss"; import { Group } from "~/components/containers/Group"; import { CellGrid } from "~/components/containers/CellGrid"; import { Panel } from "~/components/containers/Panel"; @@ -11,71 +11,63 @@ import { Button } from "~/components/input/Button"; import { Filler } from "~/components/containers/Filler"; import { InputText } from "~/components/input/InputText"; import { Icon } from "~/components/input/Icon"; +import { Grid } from "~/components/containers/Grid"; interface IProps {} const EditorExample: FC = () => ( - - -
- - - -
-
-
-
- - - -
+ + +
+ + + +
+
+
+
+ + + -
- - - + + + +
+ + + +
- -
-
+
+ + + - - - -
- + + + - - - + - - - - - - - - - - - - - - - - -
-
- + + + +
+ + ); export { EditorExample }; diff --git a/src/containers/examples/EditorExample/styles.scss b/src/containers/examples/EditorExample/styles.scss index 08b56227..aad4e49e 100644 --- a/src/containers/examples/EditorExample/styles.scss +++ b/src/containers/examples/EditorExample/styles.scss @@ -44,7 +44,7 @@ } .feature_card { - // height: 120px; + height: 120px; background: darken($main_bg_color, 6%); color: transparentize(white, 0.5); display: flex; @@ -58,7 +58,7 @@ .cover { border-radius: $radius; - background: url('http://37.192.131.144/full/attached/2017/11/f01fdaaea789915284757634baf7cd11.jpg'); + background: url("http://37.192.131.144/full/attached/2017/11/f01fdaaea789915284757634baf7cd11.jpg"); flex: 1; height: 120px; background-size: cover; @@ -79,5 +79,9 @@ } .views { - -} \ No newline at end of file + div { + display: flex; + align-items: center; + justify-content: center; + } +} diff --git a/src/sprites/Sprites.tsx b/src/sprites/Sprites.tsx index 2b0cf428..9b8b9a93 100644 --- a/src/sprites/Sprites.tsx +++ b/src/sprites/Sprites.tsx @@ -23,8 +23,7 @@ const Sprites: FC<{}> = () => ( - - + );