Signed-off-by: Avior <github@avior.me>
This commit is contained in:
Florian Bouillon 2021-09-24 17:30:58 +02:00
parent 96cd64151f
commit 9ab56544d9
25 changed files with 528 additions and 385 deletions

10
.gitignore vendored
View File

@ -1,11 +1,5 @@
module/
node_modules/ node_modules/
*.mjs
*.js
!src/dzeio/stylusUtils.js
*.d.ts
types/ types/
!rollup.config.js
!src/stylus.d.ts index.js
!.storybook/*.js
style.css style.css

600
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,10 +16,9 @@
"@types/react-dom": "^17.0.1", "@types/react-dom": "^17.0.1",
"babel-loader": "^8.2.2", "babel-loader": "^8.2.2",
"css-loader": "^5.0.2", "css-loader": "^5.0.2",
"lucide-react": "^0.16.0", "next": "^11.0.0",
"next": "^10.0.0", "react": "^17.0.0",
"react": "^16.0.0", "react-dom": "^17.0.0",
"react-dom": "^16.0.0",
"style-loader": "^2.0.0", "style-loader": "^2.0.0",
"stylus": "^0.55.0", "stylus": "^0.55.0",
"stylus-loader": "^4.3.3", "stylus-loader": "^4.3.3",
@ -28,12 +27,9 @@
"webpack": "^4.44.2" "webpack": "^4.44.2"
}, },
"peerDependencies": { "peerDependencies": {
"lucide-react": "^0.16.0", "next": "^11.0.0",
"next": "^10.0.0 || ^11.0.0", "react": "^17.0.0",
"react": "^16.0.0 || ^17.0.0", "react-dom": "^17.0.0"
"react-dom": "^16.0.0 || ^17.0.0",
"stylus": "^0.55.0",
"typescript": "^4.0.0"
}, },
"scripts": { "scripts": {
"dev": "start-storybook -s ./.storybook/public -p 6006", "dev": "start-storybook -s ./.storybook/public -p 6006",
@ -42,6 +38,7 @@
"postinstall": "rollup --config" "postinstall": "rollup --config"
}, },
"dependencies": { "dependencies": {
"lucide-react": "^0.16.0",
"rollup": "^2.44.0", "rollup": "^2.44.0",
"rollup-plugin-styles": "^3.14.1", "rollup-plugin-styles": "^3.14.1",
"rollup-plugin-typescript2": "^0.30.0", "rollup-plugin-typescript2": "^0.30.0",

View File

@ -6,8 +6,7 @@ import css from './Box.module.styl'
import Row from '../Row' import Row from '../Row'
import Col from '../Col' import Col from '../Col'
import Text from '../Text' import Text from '../Text'
import { Icon } from 'lucide-react' import { Icon } from '../interfaces'
import { ColorType } from '../interfaces'
interface Props extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> { interface Props extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
noPadding?: boolean noPadding?: boolean

View File

@ -31,15 +31,32 @@
background transparent background transparent
color @background-color color @background-color
&:not(:disabled)
&:hover &:hover
&:active &:active
&:focus &:focus
color $textOnMain color $textOnMain
&:hover
box-shadow none
&.ghost
background transparent
color black
@media (prefers-color-scheme dark)
color white
&:hover
box-shadow none
background-color rgba($main, .25)
&:active
&:focus
background-color $main
&:hover &:hover
background-color @background-color background-color @background-color
transform translateY(-2px) box-shadow 0 0 0 4px rgba(@background-color,.2)
box-shadow 0 4px 4px rgba(@background-color,.2)
&:active &:active
&:focus &:focus
@ -69,20 +86,22 @@
margin-top 0 margin-top 0
&:disabled &:disabled
background $grayLight background $lightGrayLight
color $grayDark color $darkGrayLight
transform none transform none
box-shadow none box-shadow none
cursor initial cursor initial
@media (prefers-color-scheme dark)
background $lightGrayDark
color $darkGrayDark
&.outline &.outline
border 2px solid @grayDark border 2px solid @color
background transparent background transparent
color @grayDark
@media (prefers-color-scheme dark) @media (prefers-color-scheme dark)
border 2px solid @grayLight border 2px solid $darkGrayDark
color @grayLight
&.loading &.loading
color transparent color transparent
@ -101,7 +120,13 @@
border-radius 100% border-radius 100%
height 1em height 1em
box-sizing inherit box-sizing inherit
animation ButtonLoading 1s infinite linear animation ButtonLoading .75s infinite linear
&:disabled::after
border-color transparent transparent $darkGrayLight $darkGrayLight
@media (prefers-color-scheme dark)
border-color transparent transparent $darkGrayDark $darkGrayDark
.textInner .textInner
margin-left 8px margin-left 8px
@ -137,6 +162,19 @@ btn($color, $theme)
&:focus &:focus
background-color darken(@color, 30%) background-color darken(@color, 30%)
&.ghost
background transparent
color $textColor
&:hover
box-shadow none
background-color rgba($color, .25)
&:active
&:focus
background-color $color
&:hover &:hover
background-color @background-color background-color @background-color
box-shadow 0 4px 4px rgba(@background-color,.2) box-shadow 0 4px 4px rgba(@background-color,.2)

View File

@ -1,6 +1,7 @@
import { Meta } from '@storybook/react/types-6-0' import { Meta } from '@storybook/react/types-6-0'
import React from 'react' import React from 'react'
import { Zap } from 'lucide-react' import { Zap } from 'lucide-react'
import Box from '../Box'
import Component from '.' import Component from '.'
export default { export default {
@ -8,7 +9,7 @@ export default {
component: Component component: Component
} as Meta } as Meta
export const Basic = (args: any) => <Component {...args}>Button</Component> export const Basic = (args: any) => <Box><Component {...args}>Button</Component></Box>
Basic.args = { Basic.args = {
nomargintop: true, nomargintop: true,
icon: Zap, icon: Zap,
@ -16,7 +17,7 @@ Basic.args = {
block: true block: true
} }
export const WithImg = (args: any) => <Component {...args}>Button</Component> export const WithImg = (args: any) => <Box><Component {...args}>Button</Component></Box>
WithImg.args = { WithImg.args = {
nomargintop: true, nomargintop: true,
icon: '/16-16.svg', icon: '/16-16.svg',
@ -24,7 +25,7 @@ WithImg.args = {
block: true block: true
} }
export const ExternalLinkButton = (args: any) => <Component {...args}>Button</Component> export const ExternalLinkButton = (args: any) => <Box><Component {...args}>Button</Component></Box>
ExternalLinkButton.args = { ExternalLinkButton.args = {
nomargintop: true, nomargintop: true,
href: 'https://example.com', href: 'https://example.com',

View File

@ -1,6 +1,6 @@
import React, { FC } from 'react' import React, { FC } from 'react'
import Link from '../Link' import Link from '../Link'
import { ColorType, IconProps } from '../interfaces' import { ColorType, Icon } from '../interfaces'
import { buildClassName } from '../Util' import { buildClassName } from '../Util'
import Image from '../Image' import Image from '../Image'
@ -9,12 +9,12 @@ import css from './Button.module.styl'
// MAKE OUTLINE use Fieldset instead of the current one xd // MAKE OUTLINE use Fieldset instead of the current one xd
interface Props { interface Props {
outline?: boolean
nomargintop?: boolean nomargintop?: boolean
color?: ColorType color?: ColorType
children?: React.ReactNode children?: React.ReactNode
icon?: FC<IconProps> | string icon?: Icon | string
size?: 'large' | 'small' size?: 'large' | 'small'
type?: 'outline' | 'ghost'
block?: boolean block?: boolean
href?: string href?: string
as?: string as?: string
@ -29,7 +29,7 @@ export default class Button extends React.Component<Props> {
let inner: any = this.props.children let inner: any = this.props.children
if (!this.props.loading && this.props.icon) { if (this.props.icon) {
const Icon = this.props.icon const Icon = this.props.icon
inner = ( inner = (
<> <>
@ -48,16 +48,16 @@ export default class Button extends React.Component<Props> {
const classes = buildClassName( const classes = buildClassName(
[css.button], [css.button],
[css[this.props.color as string], this.props.color], [css[this.props.color as string], this.props.color],
[css.outline, this.props.outline], [css[this.props.type as string], this.props.type],
[css.block, this.props.block], [css.block, this.props.block],
[css[this.props.size as string], this.props.size], [css[this.props.size as string], this.props.size],
[css.nomargintop, this.props.nomargintop], [css.nomargintop, this.props.nomargintop],
[css.loading, this.props.loading] [css.loading, this.props.loading]
) )
if (this.props.href) { if (this.props.href && !this.props.disabled) {
return ( return (
<Link linkProps={{onClick: this.props.onClick}} hideIcon noStyle href={this.props.href} className={buildClassName([classes], [css.disabled, this.props.disabled])}> <Link linkProps={{onClick: this.props.onClick}} noStyle href={this.props.href} className={buildClassName([classes], [css.disabled, this.props.disabled])}>
{inner} {inner}
</Link> </Link>
) )

View File

@ -1,12 +1,14 @@
@import "../config.styl"
.code .code
background #E8EAF6 .pre
padding 4px background $lightGrayLight
padding 4px 8px
border-radius 8px border-radius 8px
@media (prefers-color-scheme dark)
background $lightGrayDark
.pre .pre
border-radius 8px
padding 4px 8px
background #E8EAF6
display block display block
.code .code
padding 0 padding 0

View File

@ -1,10 +1,10 @@
import React, { FC } from 'react' import React from 'react'
import { Heart } from 'lucide-react' import { Heart } from 'lucide-react'
import Link from '../Link' import Link from '../Link'
import { Icon } from 'lucide-react'
import Text from '../Text' import Text from '../Text'
import css from './Footer.module.styl' import css from './Footer.module.styl'
import Image from 'next/image' import Image from 'next/image'
import { Icon } from '../interfaces'
interface Props { interface Props {
text?: string text?: string

View File

@ -161,8 +161,13 @@
color @border-color color @border-color
~ svg ~ svg
&::placeholder
color @border-color color @border-color
&::placeholder
color black
@media (prefers-color-scheme dark)
color white
&:invalid &:invalid
border-color $errorDark border-color $errorDark

View File

@ -2,15 +2,15 @@ import React, { FC } from 'react'
import { ChevronDown } from 'lucide-react' import { ChevronDown } from 'lucide-react'
import Text from '../Text' import Text from '../Text'
import { IconProps } from '../interfaces' import { Icon } from '../interfaces'
import { buildClassName } from '../Util' import { buildClassName } from '../Util'
import css from './Input.module.styl' import css from './Input.module.styl'
interface Props extends React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> { interface Props extends React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
id?: string id?: string
label?: string label?: string
icon?: FC<IconProps> icon?: Icon
iconRight?: FC<IconProps> iconRight?: Icon
helper?: string helper?: string
inputRef?: React.RefObject<HTMLInputElement> inputRef?: React.RefObject<HTMLInputElement>
selectRef?: React.RefObject<HTMLSelectElement> selectRef?: React.RefObject<HTMLSelectElement>

View File

@ -153,7 +153,7 @@
max-height 100% max-height 100%
&.short &.short
width 56px width 88px
.header > div .header > div
padding 0 padding 0
.header .imgContainer .header .imgContainer
@ -209,7 +209,8 @@
padding-left 16px padding-left 16px
height inherit height inherit
.navbar, .sidebar .navbar
.sidebar
ul ul
list-style none list-style none
margin 0 margin 0

View File

@ -6,7 +6,10 @@ import Text from '../Text'
export default { export default {
title: 'DZEIO/Navbar', title: 'DZEIO/Navbar',
component: Component component: Component,
parameters: {
layout: 'fullscreen'
}
} as Meta } as Meta
export const Basic: Story<any> = (args: any) => <Component {...args} /> export const Basic: Story<any> = (args: any) => <Component {...args} />

View File

@ -6,9 +6,9 @@
width 100% width 100%
top 0 top 0
left 0 left 0
background rgba($backgroundLight, .7) background rgba($lightGrayLight, .7)
@media (prefers-color-scheme dark) @media (prefers-color-scheme dark)
background rgba($backgroundDark, .7) background rgba($lightGrayDark, .7)
cursor pointer cursor pointer
z-index 200 z-index 200
animation fadeIn .3s ease-in-out 1 forwards animation fadeIn .3s ease-in-out 1 forwards

View File

@ -0,0 +1,13 @@
import { Meta } from '@storybook/react/types-6-0'
import React from 'react'
import Component from '.'
import Text from '../Text'
export default {
title: 'DZEIO/Popup',
component: Component
} as Meta
export const Basic = (args: any) => (
<Component><Text>Test</Text></Component>
)

View File

@ -9,7 +9,7 @@ import css from './Popup.module.styl'
interface Props { interface Props {
children: React.ReactNode children: React.ReactNode
onClose?: () => void onClose?: () => void
header?: Box['props'] title?: string
} }
export default class Popup extends React.Component<Props> { export default class Popup extends React.Component<Props> {
@ -17,7 +17,7 @@ export default class Popup extends React.Component<Props> {
public render = () => ( public render = () => (
<Row nomargin onClick={this.parentClose} justify="center" align="center" className={css.popup}> <Row nomargin onClick={this.parentClose} justify="center" align="center" className={css.popup}>
<Box <Box
//{...this.props.header as any} title={this.props.title}
className={css.popupChild} className={css.popupChild}
onClick={(ev) => ev.stopPropagation()} onClick={(ev) => ev.stopPropagation()}
rightHeader={ rightHeader={

View File

@ -14,7 +14,9 @@
flex-wrap nowrap flex-wrap nowrap
.nogrow > * .nogrow > *
max-width initial
flex-grow 0 flex-grow 0
flex-basis initial
for dir in 'row-reverse' 'column' 'column-reverse' for dir in 'row-reverse' 'column' 'column-reverse'
.direction-{dir} .direction-{dir}

View File

@ -6,16 +6,20 @@
tr tr
$radius = 16px $radius = 16px
td:first-child
th:first-child th:first-child
border-top-left-radius $radius border-top-left-radius $radius
border-bottom-left-radius $radius border-bottom-left-radius $radius
td:last-child
th:last-child th:last-child
border-top-right-radius $radius border-top-right-radius $radius
border-bottom-right-radius $radius border-bottom-right-radius $radius
&.horizontalBorders tr:not(:last-child) td
border-bottom 1px solid $darkGrayLight
&.verticalBorders tr td:not(:first-child)
border-left 1px solid $darkGrayLight
th th
td td
padding 16px padding 16px

View File

@ -1,5 +1,5 @@
import { Meta } from '@storybook/react/types-6-0' import { Meta } from '@storybook/react/types-6-0'
import { Copyright, Settings } from 'lucide-react' import { Settings } from 'lucide-react'
import React from 'react' import React from 'react'
import Component from '.' import Component from '.'
import Box from '../Box' import Box from '../Box'

View File

@ -7,13 +7,23 @@ interface Props {
children: React.ReactNode children: React.ReactNode
parentClassName?: string parentClassName?: string
className?: string className?: string
horizontalBorders?: boolean
verticalBorders?: boolean
} }
export default class Table extends React.Component<Props> { export default class Table extends React.Component<Props> {
public render = () => ( public render = () => (
<div className={buildClassName(css.parent, this.props.parentClassName)}> <div className={buildClassName(
<table className={buildClassName(css.table, this.props.className)}>{this.props.children}</table> css.parent,
this.props.parentClassName
)}>
<table className={buildClassName(
css.table,
this.props.className,
[css.horizontalBorders, this.props.horizontalBorders],
[css.verticalBorders, this.props.verticalBorders]
)}>{this.props.children}</table>
</div> </div>
) )

View File

@ -1,3 +1,6 @@
// not used anymore
// kept if it is used again
$path = "/assets/fonts/aileron" $path = "/assets/fonts/aileron"
@font-face @font-face

View File

@ -7,14 +7,14 @@ $infoDark = #01579B
$infoLight = #29B6F6 $infoLight = #29B6F6
$successDark = #1B5E20 $successDark = #1B5E20
$successLight = #4CAF50 $successLight = #7CB342
$errorDark = #7F0000 $errorDark = #7F0000
$errorLight = #F44336 $errorLight = #F44336
$warningDark = #C43E00 $warningDark = #C43E00
$warningLight = #FF9800 $warningLight = #FF9800
// hsl($main)
$backgroundDark = darken($main, 92%) $backgroundDark = darken($main, 92%)
$backgroundLight = lighten($main, 94%) $backgroundLight = lighten($main, 94%)
$foregroundDark = #202020 $foregroundDark = #202020
@ -28,11 +28,6 @@ $lightGrayLight = #F4F4F4
$darkGrayDark = #444 $darkGrayDark = #444
$lightGrayDark = #AAA $lightGrayDark = #AAA
// @deprecated
$grayLight = $darkGrayLight
$grayDark = $lightGrayLight
$transitionTime = .15s $transitionTime = .15s
$transitionFunction = ease-in-out $transitionFunction = ease-in-out
$transition = $transitionTime $transitionFunction $transition = $transitionTime $transitionFunction
@ -53,10 +48,6 @@ $gapSize = 16px
rem($a) rem($a)
($a / 16)rem ($a / 16)rem
// @deprecated colors
$default = $main
// See https://github.com/stylus/stylus/issues/1872#issuecomment-86553717 // See https://github.com/stylus/stylus/issues/1872#issuecomment-86553717
use('stylusUtils.js') use('stylusUtils.js')

View File

@ -1,16 +1,14 @@
@import "_aileron" //@import "_aileron"
@import "config" @import "config"
* body
*::before
*::after
box-sizing border-box box-sizing border-box
font-family Aileron, -apple-system, BlinkMacSystemFont, "Segoe UI", "Liberation Sans", sans-serif font-family: ui-system, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif
// Georgia,Cambria,"Times New Roman",Times,serif // Georgia,Cambria,"Times New Roman",Times,serif
code, pre code, pre
font-family "Fira Code", ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Liberation Mono", Menlo, Monaco, Consolas, monospace; font-family ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Liberation Mono", Menlo, Monaco, Consolas, monospace;
html html
body body

View File

@ -1,4 +1,4 @@
import { SVGAttributes } from 'react' import { FC, SVGAttributes } from 'react'
export type ColorType = 'info' | 'success' | 'error' | 'warning' export type ColorType = 'info' | 'success' | 'error' | 'warning'
@ -6,3 +6,5 @@ export interface IconProps extends SVGAttributes<SVGElement> {
color?: string color?: string
size?: string | number size?: string | number
} }
export type Icon = FC<IconProps>

View File

@ -1,7 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
/* Basic Options */ /* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ "target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */ // "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */