Skip to content

Commit

Permalink
Merge pull request #123 from Conflux-Chain/notification
Browse files Browse the repository at this point in the history
feat(notification): update width to fixed
  • Loading branch information
0x74616e67 authored Dec 14, 2020
2 parents 087bd85 + 808233f commit 9854032
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 169 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ components/date-picker/* @jnoodle
components/message/* @chain-txz
components/button-group/* @chain-txz
components/skeleton/* @chain-txz
components/notification/* @chain-txz


pages/*/components/input.mdx @yqrashawn
Expand All @@ -39,3 +40,4 @@ pages/*/components/date-picker.mdx @jnoodle
pages/*/components/message.mdx @chain-txz
pages/*/components/button-group.mdx @chain-txz
pages/*/components/skeleton.mdx @chain-txz
pages/*/components/notification.mdx @chain-txz
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`UseNotification should render correctly 1`] = `
"<div class=\\"notification-container\\"><div class=\\"notification visible right-start\\"><div class=\\"icon\\"><svg stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: currentColor;\\"><circle cx=\\"12\\" cy=\\"12\\" r=\\"10\\" fill=\\"currentColor\\"></circle><path stroke=\\"var(--zeit-icons-background)\\" d=\\"M15 9l-6 6M9 9l6 6\\"></path></svg></div><div><div class=\\"title\\">test-title</div><div class=\\"content\\">test-content</div></div><div class=\\"close\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: currentColor;\\"><path d=\\"M18 6L6 18M6 6l12 12\\"></path></svg></div><style>
"<div class=\\"notification-container\\"><div class=\\"notification visible right-start default\\"><div class=\\"icon\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: currentColor;\\"><path d=\\"M18 8A6 6 0 006 8c0 7-3 9-3 9h18s-3-2-3-9M13.73 21a2 2 0 01-3.46 0\\"></path></svg></div><div><div class=\\"title\\">test-title</div><div class=\\"content\\">test-content</div></div><div class=\\"close\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"16\\" width=\\"16\\" style=\\"color: rgb(102, 102, 102);\\"><path d=\\"M18 6L6 18M6 6l12 12\\"></path></svg><style>
.close {
position: absolute;
right: 1.1429rem;
top: 1.1429rem;
cursor: pointer;
}
</style></div><style>
.notification {
max-width: 28rem;
width: 28rem;
background-color: #fff;
color: #333;
border: 0;
border-radius: 4px;
padding: 1.1429rem;
Expand Down Expand Up @@ -45,9 +51,9 @@ exports[`UseNotification should render correctly 1`] = `
height: 1.4286rem;
width: 1.4286rem;
margin-right: calc(1.1429rem * 0.75);
flex-grow: 1;
flex-grow: 0;
flex-shrink: 0;
color: #e15c56;
color: #333;
}
.icon > :global(svg) {
width: 100%;
Expand All @@ -59,28 +65,15 @@ exports[`UseNotification should render correctly 1`] = `
font-size: 1rem;
line-height: 1.2857rem;
line-height: 1.4286rem;
margin-right: 1.1429rem;
color: #333;
}
.content {
line-height: 1.2857rem;
font-size: 1rem;
color: #999;
margin-top: calc(1.1429rem * 0.75);
}
.close {
height: 1.2857rem;
width: 1.2857rem;
cursor: pointer;
margin-left: 1.1429rem;
color: #999;
flex-grow: 1;
flex-shrink: 0;
margin-right: -0.1429rem;
margin-top: -0.1429rem;
}
.close > :global(svg) {
width: 100%;
height: 100%;
}
</style></div><style>
.notification-container {
position: fixed;
Expand All @@ -101,11 +94,17 @@ exports[`UseNotification should render correctly 1`] = `
`;

exports[`UseNotification should render with custom icon correctly 1`] = `
"<div class=\\"notification-container\\"><div class=\\"notification visible right-start\\"><div class=\\"icon\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: red;\\"><path d=\\"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 00-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0020 4.77 5.07 5.07 0 0019.91 1S18.73.65 16 2.48a13.38 13.38 0 00-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 005 4.77a5.44 5.44 0 00-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 009 18.13V22\\"></path></svg></div><div><div class=\\"title\\">test-title</div><div class=\\"content\\">test-content</div></div><div class=\\"close\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: currentColor;\\"><path d=\\"M18 6L6 18M6 6l12 12\\"></path></svg></div><style>
"<div class=\\"notification-container\\"><div class=\\"notification visible right-start default\\"><div class=\\"icon\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: red;\\"><path d=\\"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 00-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0020 4.77 5.07 5.07 0 0019.91 1S18.73.65 16 2.48a13.38 13.38 0 00-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 005 4.77a5.44 5.44 0 00-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 009 18.13V22\\"></path></svg></div><div><div class=\\"title\\">test-title</div><div class=\\"content\\">test-content</div></div><div class=\\"close\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"16\\" width=\\"16\\" style=\\"color: rgb(102, 102, 102);\\"><path d=\\"M18 6L6 18M6 6l12 12\\"></path></svg><style>
.close {
position: absolute;
right: 1.1429rem;
top: 1.1429rem;
cursor: pointer;
}
</style></div><style>
.notification {
max-width: 28rem;
width: 28rem;
background-color: #fff;
color: #333;
border: 0;
border-radius: 4px;
padding: 1.1429rem;
Expand Down Expand Up @@ -145,9 +144,9 @@ exports[`UseNotification should render with custom icon correctly 1`] = `
height: 1.4286rem;
width: 1.4286rem;
margin-right: calc(1.1429rem * 0.75);
flex-grow: 1;
flex-grow: 0;
flex-shrink: 0;
color: #e15c56;
color: #333;
}
.icon > :global(svg) {
width: 100%;
Expand All @@ -159,28 +158,15 @@ exports[`UseNotification should render with custom icon correctly 1`] = `
font-size: 1rem;
line-height: 1.2857rem;
line-height: 1.4286rem;
margin-right: 1.1429rem;
color: #333;
}
.content {
line-height: 1.2857rem;
font-size: 1rem;
color: #999;
margin-top: calc(1.1429rem * 0.75);
}
.close {
height: 1.2857rem;
width: 1.2857rem;
cursor: pointer;
margin-left: 1.1429rem;
color: #999;
flex-grow: 1;
flex-shrink: 0;
margin-right: -0.1429rem;
margin-top: -0.1429rem;
}
.close > :global(svg) {
width: 100%;
height: 100%;
}
</style></div><style>
.notification-container {
position: fixed;
Expand All @@ -201,11 +187,17 @@ exports[`UseNotification should render with custom icon correctly 1`] = `
`;

exports[`UseNotification should work with different placement 1`] = `
"<div class=\\"notification-container\\"><div class=\\"notification visible right-start\\"><div class=\\"icon\\"><svg stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: currentColor;\\"><circle cx=\\"12\\" cy=\\"12\\" r=\\"10\\" fill=\\"currentColor\\"></circle><path stroke=\\"var(--zeit-icons-background)\\" d=\\"M15 9l-6 6M9 9l6 6\\"></path></svg></div><div><div class=\\"title\\">test-title</div><div class=\\"content\\">right-start test-content</div></div><div class=\\"close\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: currentColor;\\"><path d=\\"M18 6L6 18M6 6l12 12\\"></path></svg></div><style>
"<div class=\\"notification-container\\"><div class=\\"notification visible right-start default\\"><div class=\\"icon\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: currentColor;\\"><path d=\\"M18 8A6 6 0 006 8c0 7-3 9-3 9h18s-3-2-3-9M13.73 21a2 2 0 01-3.46 0\\"></path></svg></div><div><div class=\\"title\\">test-title</div><div class=\\"content\\">right-start test-content</div></div><div class=\\"close\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"16\\" width=\\"16\\" style=\\"color: rgb(102, 102, 102);\\"><path d=\\"M18 6L6 18M6 6l12 12\\"></path></svg><style>
.close {
position: absolute;
right: 1.1429rem;
top: 1.1429rem;
cursor: pointer;
}
</style></div><style>
.notification {
max-width: 28rem;
width: 28rem;
background-color: #fff;
color: #333;
border: 0;
border-radius: 4px;
padding: 1.1429rem;
Expand Down Expand Up @@ -245,9 +237,9 @@ exports[`UseNotification should work with different placement 1`] = `
height: 1.4286rem;
width: 1.4286rem;
margin-right: calc(1.1429rem * 0.75);
flex-grow: 1;
flex-grow: 0;
flex-shrink: 0;
color: #e15c56;
color: #333;
}
.icon > :global(svg) {
width: 100%;
Expand All @@ -259,33 +251,26 @@ exports[`UseNotification should work with different placement 1`] = `
font-size: 1rem;
line-height: 1.2857rem;
line-height: 1.4286rem;
margin-right: 1.1429rem;
color: #333;
}
.content {
line-height: 1.2857rem;
font-size: 1rem;
color: #999;
margin-top: calc(1.1429rem * 0.75);
}
.close {
height: 1.2857rem;
width: 1.2857rem;
cursor: pointer;
margin-left: 1.1429rem;
color: #999;
flex-grow: 1;
flex-shrink: 0;
margin-right: -0.1429rem;
margin-top: -0.1429rem;
}
.close > :global(svg) {
width: 100%;
height: 100%;
}
</style></div><div class=\\"notification visible left-start\\"><div class=\\"icon\\"><svg stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: currentColor;\\"><circle cx=\\"12\\" cy=\\"12\\" r=\\"10\\" fill=\\"currentColor\\"></circle><path stroke=\\"var(--zeit-icons-background)\\" d=\\"M15 9l-6 6M9 9l6 6\\"></path></svg></div><div><div class=\\"title\\">test-title</div><div class=\\"content\\">left-start test-content</div></div><div class=\\"close\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: currentColor;\\"><path d=\\"M18 6L6 18M6 6l12 12\\"></path></svg></div><style>
</style></div><div class=\\"notification visible left-start default\\"><div class=\\"icon\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"24\\" width=\\"24\\" style=\\"color: currentColor;\\"><path d=\\"M18 8A6 6 0 006 8c0 7-3 9-3 9h18s-3-2-3-9M13.73 21a2 2 0 01-3.46 0\\"></path></svg></div><div><div class=\\"title\\">test-title</div><div class=\\"content\\">left-start test-content</div></div><div class=\\"close\\"><svg fill=\\"none\\" stroke=\\"currentColor\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" stroke-width=\\"1.5\\" shape-rendering=\\"geometricPrecision\\" viewBox=\\"0 0 24 24\\" height=\\"16\\" width=\\"16\\" style=\\"color: rgb(102, 102, 102);\\"><path d=\\"M18 6L6 18M6 6l12 12\\"></path></svg><style>
.close {
position: absolute;
right: 1.1429rem;
top: 1.1429rem;
cursor: pointer;
}
</style></div><style>
.notification {
max-width: 28rem;
width: 28rem;
background-color: #fff;
color: #333;
border: 0;
border-radius: 4px;
padding: 1.1429rem;
Expand Down Expand Up @@ -325,9 +310,9 @@ exports[`UseNotification should work with different placement 1`] = `
height: 1.4286rem;
width: 1.4286rem;
margin-right: calc(1.1429rem * 0.75);
flex-grow: 1;
flex-grow: 0;
flex-shrink: 0;
color: #e15c56;
color: #333;
}
.icon > :global(svg) {
width: 100%;
Expand All @@ -339,28 +324,15 @@ exports[`UseNotification should work with different placement 1`] = `
font-size: 1rem;
line-height: 1.2857rem;
line-height: 1.4286rem;
margin-right: 1.1429rem;
color: #333;
}
.content {
line-height: 1.2857rem;
font-size: 1rem;
color: #999;
margin-top: calc(1.1429rem * 0.75);
}
.close {
height: 1.2857rem;
width: 1.2857rem;
cursor: pointer;
margin-left: 1.1429rem;
color: #999;
flex-grow: 1;
flex-shrink: 0;
margin-right: -0.1429rem;
margin-top: -0.1429rem;
}
.close > :global(svg) {
width: 100%;
height: 100%;
}
</style></div><style>
.notification-container {
position: fixed;
Expand Down
40 changes: 40 additions & 0 deletions components/use-notifications/modal-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react'
import { X } from '@zeit-ui/react-icons'
import withDefaults from '../utils/with-defaults'
import useTheme from '../styles/use-theme'

interface Props {
size?: number
color?: string
onClick?: (event: React.MouseEvent) => void
}

const defaultProps = {
size: 14,
}

export type ModalIconProps = Props

const ModalIcon: React.FC<ModalIconProps & typeof defaultProps> = ({ size, color, onClick }) => {
const clickHandler = (event: React.MouseEvent) => {
onClick && onClick(event)
}
const theme = useTheme()
return (
<div className="close" onClick={clickHandler}>
<X size={size} color={color} />
<style jsx>{`
.close {
position: absolute;
right: ${theme.layout.gap};
top: ${theme.layout.gap};
cursor: pointer;
}
`}</style>
</div>
)
}

const MemoModalIcon = React.memo(ModalIcon)

export default withDefaults(MemoModalIcon, defaultProps)
Loading

0 comments on commit 9854032

Please sign in to comment.