mirror of
https://github.com/dzeiocom/components.git
synced 2025-06-17 04:59:20 +00:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
6c69dac257
|
|||
0e85ce9722
|
|||
48d60f60e0
|
|||
d49c194654
|
|||
6f1c366289
|
|||
8ac899b3f0
|
|||
7ddce9ec85
|
|||
f3597f3008
|
|||
fe6b552a69 | |||
58a48b28fd | |||
5675d8f225
|
|||
0f7999ac50 | |||
d43e62f04a | |||
c680b613cc |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/components",
|
"name": "@dzeio/components",
|
||||||
"version": "0.8.5",
|
"version": "0.10.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"types": "./types/index.d.ts",
|
"types": "./types/index.d.ts",
|
||||||
|
@ -12,6 +12,22 @@
|
|||||||
border-color $grayLight
|
border-color $grayLight
|
||||||
|
|
||||||
|
|
||||||
|
.header
|
||||||
|
padding 16px
|
||||||
|
|
||||||
|
+ .body
|
||||||
|
padding-top 0
|
||||||
|
|
||||||
|
.title
|
||||||
|
font-weight bold
|
||||||
|
font-size rem(18)
|
||||||
|
margin 0 0 8px
|
||||||
|
|
||||||
|
.subtitle
|
||||||
|
font-size rem(16)
|
||||||
|
margin 0
|
||||||
|
|
||||||
|
|
||||||
// BODY
|
// BODY
|
||||||
.body
|
.body
|
||||||
padding 0 16px 16px
|
padding 16px
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
@import "../../config.styl"
|
|
||||||
|
|
||||||
.header
|
|
||||||
padding 16px
|
|
||||||
|
|
||||||
.title
|
|
||||||
font-weight bold
|
|
||||||
font-size rem(18)
|
|
||||||
margin 0 0 8px
|
|
||||||
|
|
||||||
.subtitle
|
|
||||||
font-size rem(16)
|
|
||||||
margin 0
|
|
@ -1,56 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
|
|
||||||
import { buildClassName } from '../../Util'
|
|
||||||
import css from './BoxHeader.module.styl'
|
|
||||||
import Row from '../../Row'
|
|
||||||
import Col from '../../Col'
|
|
||||||
import Text from '../../Text'
|
|
||||||
|
|
||||||
|
|
||||||
export interface Props {
|
|
||||||
title?: string
|
|
||||||
titleColSize?: number
|
|
||||||
subtitle?: string
|
|
||||||
titleClassName?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class BoxHeader extends React.Component<Props> {
|
|
||||||
|
|
||||||
public render = () => (
|
|
||||||
<>
|
|
||||||
<div data-t="true" className={buildClassName(
|
|
||||||
css.header
|
|
||||||
)}>
|
|
||||||
<Row nomargin justify="space-between">
|
|
||||||
<Col>
|
|
||||||
{this.props.title && (
|
|
||||||
<Text className={buildClassName(css.title, this.props.titleClassName)}>{this.props.title}</Text>
|
|
||||||
)}
|
|
||||||
{this.props.subtitle && (
|
|
||||||
<Text className={css.subtitle}>{this.props.subtitle}</Text>
|
|
||||||
)}
|
|
||||||
</Col>
|
|
||||||
{this.props.children && (
|
|
||||||
<Col nogrow>
|
|
||||||
<Row justify="flex-end">
|
|
||||||
{this.props.children}
|
|
||||||
</Row>
|
|
||||||
</Col>
|
|
||||||
)}
|
|
||||||
</Row>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Header
|
|
||||||
delimiter?: boolean
|
|
||||||
picture?: string // url
|
|
||||||
category?: string // subtitle but above title
|
|
||||||
title string
|
|
||||||
subtitle string
|
|
||||||
center?: boolean // if Center children is not used
|
|
||||||
children?: content
|
|
||||||
*/
|
|
@ -1,9 +1,11 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import BoxHeader from './BoxHeader'
|
|
||||||
import { buildClassName } from '../Util'
|
import { buildClassName } from '../Util'
|
||||||
|
|
||||||
import css from './Box.module.styl'
|
import css from './Box.module.styl'
|
||||||
|
import Row from '../Row'
|
||||||
|
import Col from '../Col'
|
||||||
|
import Text from '../Text'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
||||||
@ -37,14 +39,27 @@ export default class Box extends React.Component<Props> {
|
|||||||
className={buildClassName(css.box, this.props.className, [css.outline, this.props.outline])}
|
className={buildClassName(css.box, this.props.className, [css.outline, this.props.outline])}
|
||||||
>
|
>
|
||||||
{(this.props.headerButtons || this.props.title || this.props.titleColSize || this.props.subtitle || this.props.delimiter || this.props.titleClassName) && (
|
{(this.props.headerButtons || this.props.title || this.props.titleColSize || this.props.subtitle || this.props.delimiter || this.props.titleClassName) && (
|
||||||
<BoxHeader
|
<div className={buildClassName(
|
||||||
title={this.props.title}
|
css.header
|
||||||
titleColSize={this.props.titleColSize}
|
)}>
|
||||||
subtitle={this.props.subtitle}
|
<Row nomargin justify="space-between">
|
||||||
titleClassName={this.props.titleClassName}
|
<Col>
|
||||||
>
|
{this.props.title && (
|
||||||
{this.props.headerButtons}
|
<Text className={buildClassName(css.title, this.props.titleClassName)}>{this.props.title}</Text>
|
||||||
</BoxHeader>
|
)}
|
||||||
|
{this.props.subtitle && (
|
||||||
|
<Text className={css.subtitle}>{this.props.subtitle}</Text>
|
||||||
|
)}
|
||||||
|
</Col>
|
||||||
|
{this.props.children && (
|
||||||
|
<Col nogrow>
|
||||||
|
<Row justify="flex-end">
|
||||||
|
{this.props.headerButtons}
|
||||||
|
</Row>
|
||||||
|
</Col>
|
||||||
|
)}
|
||||||
|
</Row>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
{this.props.children && (
|
{this.props.children && (
|
||||||
<div className={buildClassName([css.body, !this.props.noPadding])}>
|
<div className={buildClassName([css.body, !this.props.noPadding])}>
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
li
|
li
|
||||||
display inline-block
|
display inline-block
|
||||||
|
|
||||||
|
&.socials a
|
||||||
|
padding 0 8px
|
||||||
|
|
||||||
.animation
|
.animation
|
||||||
animation grow 1s linear infinite
|
animation grow 1s linear infinite
|
||||||
display inline-block
|
display inline-block
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Meta, Story } from '@storybook/react/types-6-0'
|
import { Meta, Story } from '@storybook/react/types-6-0'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import { Zap } from 'react-feather'
|
||||||
import Component from '.'
|
import Component from '.'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -10,6 +11,9 @@ export default {
|
|||||||
export const Basic: Story<any> = (args: any) => <Component {...args} />
|
export const Basic: Story<any> = (args: any) => <Component {...args} />
|
||||||
|
|
||||||
let tmp = Basic.bind({})
|
let tmp = Basic.bind({})
|
||||||
tmp.args = {links: [{name: 'test1', path: '/'}, {name: 'test2', path: '/'}, {name: 'test3', path: '/'}]}
|
tmp.args = {
|
||||||
|
links: [{name: 'test1', path: '/'}, {name: 'test2', path: '/'}, {name: 'test3', path: '/'}],
|
||||||
|
socials: [{icon: Zap, href: '/'}, {icon: '/16-16.svg', href: '/'}, {icon: Zap, href: '/'}]
|
||||||
|
}
|
||||||
|
|
||||||
export const Normal = tmp
|
export const Normal = tmp
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import React from 'react'
|
import React, { FC } from 'react'
|
||||||
import { Heart } from 'react-feather'
|
import { Heart } from 'react-feather'
|
||||||
import Link from '../Link'
|
import Link from '../Link'
|
||||||
|
import { Icon } from 'react-feather'
|
||||||
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'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
text?: string
|
text?: string
|
||||||
@ -12,6 +13,10 @@ interface Props {
|
|||||||
path: string
|
path: string
|
||||||
name: string
|
name: string
|
||||||
}>
|
}>
|
||||||
|
socials?: Array<{
|
||||||
|
href: string
|
||||||
|
icon: Icon | string
|
||||||
|
}>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Footer extends React.Component<Props> {
|
export default class Footer extends React.Component<Props> {
|
||||||
@ -27,6 +32,17 @@ export default class Footer extends React.Component<Props> {
|
|||||||
<li key={l.path}><Text>{index !== 0 && (<> - </>)}<Link href={l.path}>{l.name}</Link></Text></li>
|
<li key={l.path}><Text>{index !== 0 && (<> - </>)}<Link href={l.path}>{l.name}</Link></Text></li>
|
||||||
))}</ul>
|
))}</ul>
|
||||||
)}
|
)}
|
||||||
|
{this.props.socials && (
|
||||||
|
<ul className={css.socials}>{this.props.socials.map((l, index) => (
|
||||||
|
<li key={l.href}><Text><Link hideIcon noStyle href={l.href}>
|
||||||
|
{typeof l.icon === 'string' ? (
|
||||||
|
<Image width={24} height={24} src={l.icon} />
|
||||||
|
) : (
|
||||||
|
<l.icon size={24} />
|
||||||
|
)}
|
||||||
|
</Link></Text></li>
|
||||||
|
))}</ul>
|
||||||
|
)}
|
||||||
</footer>
|
</footer>
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -1,43 +1,34 @@
|
|||||||
.parent
|
.parent
|
||||||
position relative
|
transition-property padding, width, height, background, top, left
|
||||||
display inline-flex
|
transition-duration .3s
|
||||||
|
transition-timing-function ease-in-out
|
||||||
|
cursor pointer
|
||||||
|
|
||||||
.image
|
// Animation part 1
|
||||||
transition .3s
|
// this is set to move the image from a normal position to a fixed one
|
||||||
object-fit contain
|
// + one the image itself there is style with position
|
||||||
z-index 2
|
.fs1
|
||||||
|
position fixed
|
||||||
&.ph1
|
z-index 1000
|
||||||
position fixed
|
padding 0
|
||||||
transition 0s
|
> div
|
||||||
|
width 100%
|
||||||
|
|
||||||
&.ph2
|
|
||||||
width 100% !important
|
|
||||||
position fixed
|
|
||||||
max-width 100% !important
|
|
||||||
max-height 100% !important
|
|
||||||
box-sizing border-box
|
|
||||||
padding 5%
|
|
||||||
top 0 !important
|
|
||||||
left 0 !important
|
|
||||||
height 100%
|
height 100%
|
||||||
background #000000A0
|
|
||||||
|
|
||||||
|
// Animation part 2
|
||||||
|
// this animation move the card from its original pos to a fullscreen one
|
||||||
|
.fs2
|
||||||
|
padding 8px
|
||||||
|
width 100% !important
|
||||||
|
height 100vh !important
|
||||||
|
background rgba(black, 50%)
|
||||||
|
// padding 0
|
||||||
|
user-select none
|
||||||
|
top 0 !important
|
||||||
|
left 0 !important
|
||||||
|
> div
|
||||||
|
width 100%
|
||||||
|
height 100%
|
||||||
|
|
||||||
&.after
|
.body
|
||||||
background #00000000
|
|
||||||
// height 100%
|
|
||||||
box-sizing border-box
|
|
||||||
position fixed
|
|
||||||
// width 100%
|
|
||||||
z-index 0
|
|
||||||
padding initial
|
|
||||||
|
|
||||||
|
|
||||||
.hideOverflow
|
|
||||||
overflow hidden
|
overflow hidden
|
||||||
|
|
||||||
|
|
||||||
.none
|
|
||||||
display none
|
|
||||||
|
@ -1,182 +1,103 @@
|
|||||||
import React from 'react'
|
import React, { MouseEventHandler } from 'react'
|
||||||
import { buildClassName } from '../Util'
|
|
||||||
import NextImage from 'next/image'
|
|
||||||
|
|
||||||
|
import NextImage, { ImageProps } from 'next/image'
|
||||||
import css from './Image.module.styl'
|
import css from './Image.module.styl'
|
||||||
|
import { buildClassName } from '../Util'
|
||||||
|
|
||||||
export interface ImageProps {
|
interface Props {
|
||||||
src: string
|
imageProps: ImageProps
|
||||||
deleteOnError?: boolean
|
/**
|
||||||
canFullscreen?: boolean
|
* Define if the image can go fullscreen
|
||||||
width: number
|
*/
|
||||||
height: number
|
fullscreen?: boolean
|
||||||
alt?: string
|
|
||||||
|
|
||||||
// ClassNames
|
|
||||||
parentClassName?: string
|
|
||||||
className?: string
|
|
||||||
|
|
||||||
// Events
|
|
||||||
onClick?: () => void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type evType<T = HTMLImageElement> = React.SyntheticEvent<T, Event>
|
interface States {
|
||||||
|
image?: {
|
||||||
|
size: [number | string, number | string]
|
||||||
|
pos: [number, number]
|
||||||
|
}
|
||||||
|
transform?: [number, number]
|
||||||
|
className?: string
|
||||||
|
}
|
||||||
|
|
||||||
export default class Image extends React.Component<ImageProps> {
|
export default class Image extends React.Component<Props, States> {
|
||||||
|
|
||||||
private ref: React.RefObject<HTMLImageElement> = React.createRef()
|
public state: States = {}
|
||||||
private plchldr: React.RefObject<HTMLDivElement> = React.createRef()
|
|
||||||
private parent: React.RefObject<HTMLDivElement> = React.createRef()
|
|
||||||
private pic: React.RefObject<HTMLDivElement> = React.createRef()
|
|
||||||
|
|
||||||
private cardPos: Array<number> = []
|
private animationCount = 0
|
||||||
private cardSize: Array<number> = []
|
|
||||||
|
|
||||||
private isFullscreen = false
|
public componentDidUpdate() {
|
||||||
|
if (!this.props.fullscreen) {return}
|
||||||
public async componentDidMount() {
|
if (this.state.image) {
|
||||||
if (this.props.canFullscreen) {
|
document.body.classList.add(css.body)
|
||||||
window.addEventListener('scroll', this.onScroll)
|
} else {
|
||||||
window.addEventListener('resize', this.onResize)
|
document.body.classList.remove(css.body)
|
||||||
this.onScroll()
|
|
||||||
this.onResize()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async componentDidUpdate() {
|
public componentWillUnmount() {
|
||||||
this.pic.current?.classList.remove(css.none)
|
if (!this.props.fullscreen) {return}
|
||||||
if (this.props.canFullscreen) {
|
document.body.classList.remove(css.body)
|
||||||
this.onScroll()
|
|
||||||
this.onResize()
|
|
||||||
}
|
|
||||||
if (this.isFullscreen) {
|
|
||||||
this.onClick()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async componentWillUnmount() {
|
|
||||||
if (this.props.canFullscreen) {
|
|
||||||
window.removeEventListener('scroll', this.onScroll)
|
|
||||||
window.removeEventListener('resize', this.onResize)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const pic = (
|
if (!this.props.fullscreen) {
|
||||||
<div ref={this.pic} className={buildClassName(this.props.parentClassName, css.parent)}>
|
return <NextImage
|
||||||
<NextImage
|
{...this.props.imageProps}
|
||||||
className={buildClassName([css.image], [this.props.className])}
|
objectFit="contain"
|
||||||
src={this.props.src}
|
/>
|
||||||
onClick={this.props.canFullscreen ? this.onClick : this.props.onClick}
|
}
|
||||||
onError={this.props.deleteOnError && this.onError || undefined}
|
return (
|
||||||
// layout="fill"
|
<>
|
||||||
width={this.props.width}
|
{this.state.image && (
|
||||||
height={this.props.height}
|
<div style={{width: this.state.image.size[0], height: this.state.image.size[1]}}></div>
|
||||||
alt={this.props.alt}
|
)}
|
||||||
/>
|
|
||||||
</div>
|
<div
|
||||||
)
|
className={buildClassName(css.parent, [css.fs1, this.state.image], [this.state.className, this.state.image])}
|
||||||
if (this.props.canFullscreen) {
|
style={this.state.image ? {
|
||||||
return (
|
top: this.state.image.pos[1],
|
||||||
<div ref={this.parent}>
|
left: this.state.image.pos[0],
|
||||||
<div ref={this.plchldr} className={css.none}></div>
|
width: this.state.image.size[0],
|
||||||
{pic}
|
height: this.state.image.size[1]
|
||||||
|
} : undefined}
|
||||||
|
onClick={this.props.fullscreen ? this.onClick : undefined}
|
||||||
|
|
||||||
|
>
|
||||||
|
<NextImage
|
||||||
|
priority
|
||||||
|
quality={100}
|
||||||
|
{...this.props.imageProps}
|
||||||
|
objectFit="contain"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
</>
|
||||||
}
|
)
|
||||||
return pic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private onScroll = async () => {
|
private onClick: MouseEventHandler<HTMLDivElement> = (ev) => {
|
||||||
if (!this.ref.current || this.isFullscreen || !this.props.canFullscreen) {
|
const target = ev.currentTarget
|
||||||
return
|
const isFullscreen = !(this.state.image && this.state.className)
|
||||||
}
|
const currentCount = ++this.animationCount
|
||||||
|
this.setState(isFullscreen ? {
|
||||||
this.cardPos = [this.ref.current.offsetTop - window.scrollY, this.ref.current.offsetLeft - window.scrollX]
|
image: this.state.image ?? {
|
||||||
this.ref.current.style.top = this.cardPos[0] + 'px'
|
size: [target.offsetWidth, target.offsetHeight],
|
||||||
this.ref.current.style.left = this.cardPos[1] + 'px'
|
pos: [target.offsetLeft - window.scrollX, target.offsetTop - window.scrollY]
|
||||||
}
|
},
|
||||||
|
className: undefined
|
||||||
private onResize = async () => {
|
} : {
|
||||||
if (!this.ref.current || !this.plchldr.current || !this.props.canFullscreen || this.isFullscreen) {
|
className: undefined
|
||||||
return
|
}, () => {
|
||||||
}
|
|
||||||
let tmp = [this.ref.current.offsetHeight, this.ref.current.offsetWidth]
|
|
||||||
if (this.parent.current) {
|
|
||||||
tmp = [this.parent.current.offsetHeight, this.ref.current.offsetWidth]
|
|
||||||
}
|
|
||||||
this.plchldr.current.style.width = `${tmp[1]}px`
|
|
||||||
this.plchldr.current.style.height = `${tmp[0]}px`
|
|
||||||
}
|
|
||||||
|
|
||||||
private onClick = async () => {
|
|
||||||
if (!this.ref.current || !this.props.canFullscreen || !this.plchldr.current) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (this.props.onClick) {
|
|
||||||
this.props.onClick()
|
|
||||||
}
|
|
||||||
|
|
||||||
const i = this.ref.current
|
|
||||||
const c = this.plchldr.current
|
|
||||||
const body = document.body
|
|
||||||
i.style.top = this.cardPos[0] + 'px'
|
|
||||||
i.style.left = this.cardPos[1] + 'px'
|
|
||||||
|
|
||||||
if (this.isFullscreen) {
|
|
||||||
i.style.width = this.cardSize[1] + 'px'
|
|
||||||
i.style.height = this.cardSize[0] + 'px'
|
|
||||||
body.classList.remove(css.hideOverflow)
|
|
||||||
i.classList.remove(css.ph2)
|
|
||||||
i.classList.add(css.after)
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (i.classList.contains(css.ph2) || i.classList.contains(css.ph1) || this.isFullscreen) {
|
if (this.animationCount !== currentCount) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const w = this.valToPixel(this.props.width)
|
this.setState({
|
||||||
const mh = this.valToPixel(this.props?.height)
|
className: isFullscreen ? css.fs2 : undefined,
|
||||||
const mw = this.valToPixel(this.props?.width)
|
image: isFullscreen ? this.state.image : undefined
|
||||||
c.classList.add(css.none)
|
})
|
||||||
i.style.height = ''
|
}, isFullscreen ? 10 : 310)
|
||||||
i.style.width = w
|
})
|
||||||
i.style.maxHeight = mh
|
|
||||||
i.style.maxWidth = mw
|
|
||||||
i.classList.remove(css.after)
|
|
||||||
}, 350)
|
|
||||||
this.isFullscreen = false
|
|
||||||
} else {
|
|
||||||
i.classList.add(css.ph1)
|
|
||||||
c.classList.remove(css.none)
|
|
||||||
i.classList.add(css.ph2)
|
|
||||||
i.classList.remove(css.ph1)
|
|
||||||
body.classList.add(css.hideOverflow)
|
|
||||||
this.isFullscreen = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private valToPixel(value: number|string|undefined): string {
|
|
||||||
if (typeof value === 'number') {
|
|
||||||
return `${value}px`
|
|
||||||
}
|
|
||||||
if (typeof value === 'undefined') {
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
private onLoad = async (ev: evType) => {
|
|
||||||
ev.currentTarget.style.height = ''
|
|
||||||
ev.currentTarget.style.width = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
private onError = async (ev: evType) => {
|
|
||||||
this.w('Picture not loaded', ev.currentTarget.src)
|
|
||||||
ev.currentTarget.parentElement?.classList.add(css.none)
|
|
||||||
}
|
|
||||||
|
|
||||||
private w(...messages: any) {
|
|
||||||
console.warn('[ Picture ]', ...messages)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@
|
|||||||
~ svg
|
~ svg
|
||||||
color @border-color
|
color @border-color
|
||||||
&:invalid
|
&:invalid
|
||||||
border-color $errorLight
|
border-color $errorDark
|
||||||
|
|
||||||
~ label
|
~ label
|
||||||
color @border-color
|
color @border-color
|
||||||
@ -188,7 +188,7 @@
|
|||||||
~ svg
|
~ svg
|
||||||
color @border-color
|
color @border-color
|
||||||
@media (prefers-color-scheme dark)
|
@media (prefers-color-scheme dark)
|
||||||
border-color $errorDark
|
border-color $errorLight
|
||||||
|
|
||||||
~ label
|
~ label
|
||||||
color @border-color
|
color @border-color
|
||||||
@ -229,7 +229,7 @@
|
|||||||
background #1c1c1c
|
background #1c1c1c
|
||||||
&:focus
|
&:focus
|
||||||
background rgba(gray, .3)
|
background rgba(gray, .3)
|
||||||
border-bottom 2px solid $default
|
border-bottom 2px solid $main
|
||||||
|
|
||||||
&.opaque
|
&.opaque
|
||||||
background white
|
background white
|
||||||
|
@ -7,7 +7,9 @@ export default {
|
|||||||
component: Component,
|
component: Component,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
href: {control: 'text', defaultValue: 'https://www.dzeio.com'},
|
href: {control: 'text', defaultValue: 'https://www.dzeio.com'},
|
||||||
text: {control: 'text', defaultValue: 'Dzeio'}
|
text: {control: 'text', defaultValue: 'Dzeio'},
|
||||||
|
external: {control: 'boolean'},
|
||||||
|
hideIcon: {control: 'boolean'}
|
||||||
}
|
}
|
||||||
} as Meta
|
} as Meta
|
||||||
|
|
||||||
|
@ -19,23 +19,35 @@ interface Props {
|
|||||||
* Override external detection system
|
* Override external detection system
|
||||||
*/
|
*/
|
||||||
external?: boolean
|
external?: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* force hiding the icon
|
||||||
|
*/
|
||||||
|
hideIcon?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Link extends React.Component<Props> {
|
export default class Link extends React.Component<Props> {
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const external = this.props.external ?? this.props.href.startsWith('http')
|
const isExternal = this.props.href.startsWith('http')
|
||||||
if (external) {
|
const externalProps = this.props.external ? {
|
||||||
|
rel: 'noreferrer nofollow',
|
||||||
|
target: '_blank'
|
||||||
|
} : {}
|
||||||
|
|
||||||
|
if (isExternal) {
|
||||||
// external link
|
// external link
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
{...this.props.linkProps}
|
{...this.props.linkProps}
|
||||||
className={buildClassName(this.props.className, [css.link, !this.props.noStyle])}
|
className={buildClassName(this.props.className, [css.link, !this.props.noStyle])}
|
||||||
href={this.props.href}
|
href={this.props.href}
|
||||||
rel="noreferrer nofollow"
|
{...externalProps}
|
||||||
target="_blank"
|
|
||||||
>
|
>
|
||||||
{this.props.children}<ExternalLink size={16} className={css.icon} />
|
{this.props.children}
|
||||||
|
{(this.props.external !== false && !this.props.hideIcon) && (
|
||||||
|
<ExternalLink size={16} className={css.icon} />
|
||||||
|
)}
|
||||||
</a>
|
</a>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -43,6 +55,7 @@ export default class Link extends React.Component<Props> {
|
|||||||
<NextLink href={this.props.href}>
|
<NextLink href={this.props.href}>
|
||||||
<a
|
<a
|
||||||
{...this.props.linkProps}
|
{...this.props.linkProps}
|
||||||
|
{...externalProps}
|
||||||
className={buildClassName(this.props.className, [css.link, !this.props.noStyle])}
|
className={buildClassName(this.props.className, [css.link, !this.props.noStyle])}
|
||||||
>{this.props.children}</a>
|
>{this.props.children}</a>
|
||||||
</NextLink>
|
</NextLink>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
bottom 0
|
bottom 0
|
||||||
left 0
|
left 0
|
||||||
padding 0 16px
|
padding 0 16px
|
||||||
|
z-index 400
|
||||||
max-width 25%
|
max-width 25%
|
||||||
@media (max-width $tablet)
|
@media (max-width $tablet)
|
||||||
max-width 50%
|
max-width 50%
|
||||||
|
@ -3,14 +3,13 @@ import { X } from 'react-feather'
|
|||||||
import Text from '../Text'
|
import Text from '../Text'
|
||||||
import Box from '../Box'
|
import Box from '../Box'
|
||||||
import Row from '../Row'
|
import Row from '../Row'
|
||||||
import { Props as HeaderProps } from '../Box/BoxHeader'
|
|
||||||
|
|
||||||
import css from './Popup.module.styl'
|
import css from './Popup.module.styl'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
onClose?: () => void
|
onClose?: () => void
|
||||||
header?: HeaderProps
|
header?: Box['props']
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Popup extends React.Component<Props> {
|
export default class Popup extends React.Component<Props> {
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
|
@import '../config'
|
||||||
|
|
||||||
.table
|
.table
|
||||||
border-spacing 0
|
border-spacing 0
|
||||||
border 2px solid #EEE
|
border 2px solid $grayDark
|
||||||
|
@media (prefers-color-scheme dark)
|
||||||
|
border-color $grayLight
|
||||||
border-radius 4px
|
border-radius 4px
|
||||||
width 100%
|
width 100%
|
||||||
|
|
||||||
td
|
td
|
||||||
border-top 1px solid #EEE
|
border-top 1px solid $grayDark
|
||||||
|
@media (prefers-color-scheme dark)
|
||||||
|
border-color $grayLight
|
||||||
|
|
||||||
th
|
th
|
||||||
td
|
td
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
.text
|
.text
|
||||||
margin 0
|
margin 0
|
||||||
|
|
||||||
|
+ .text
|
||||||
|
margin-top 8px
|
||||||
|
|
||||||
.white
|
.white
|
||||||
color white
|
color white
|
||||||
|
|
||||||
|
15
src/dzeio/Text/Text.stories.tsx
Normal file
15
src/dzeio/Text/Text.stories.tsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { Meta } from '@storybook/react/types-6-0'
|
||||||
|
import React from 'react'
|
||||||
|
import Component from '.'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'DZEIO/Text',
|
||||||
|
component: Component
|
||||||
|
} as Meta
|
||||||
|
|
||||||
|
export const Basic = (args: any) => (
|
||||||
|
<>
|
||||||
|
<Component {...args}>TExt</Component>
|
||||||
|
<Component {...args}>TExt</Component>
|
||||||
|
</>
|
||||||
|
)
|
Reference in New Issue
Block a user