Skip to content

Icons, Fonts & Notifications #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 2, 2020
Prev Previous commit
Next Next commit
cleanup load processes
  • Loading branch information
ShMcK committed Feb 2, 2020
commit f7d82c8800eabed606e558f8aca97d759d4dc9d1
27 changes: 23 additions & 4 deletions web-app/src/components/Message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,34 @@ import { Message as AlifdMessage } from '@alifd/next'
import * as React from 'react'

interface Props {
type: 'error'
type?: 'success' | 'warning' | 'error' | 'notice' | 'help' | 'loading'
title: string
description?: string
shape?: 'inline' | 'addon' | 'toast'
size?: 'medium' | 'large'
children?: string
closeable?: boolean
onClose?: () => void
handleClose?: () => void
}

const Message = (props: Props) => {
const [visible, setVisible] = React.useState(true)
function onClose() {
if (props.onClose) {
props.onClose()
}
setVisible(false)
}
return (
<AlifdMessage type={props.type} title={props.title}>
{props.description}
<AlifdMessage
type={props.type}
visible={visible}
title={props.title}
closeable={props.closeable}
onClose={onClose}
shape={props.shape}
>
{props.children}
</AlifdMessage>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Message as AlifdMessage } from '@alifd/next'
import Message from '../Message'
import * as React from 'react'
import * as T from 'typings'
import { css, jsx } from '@emotion/core'
Expand All @@ -15,19 +15,19 @@ const styles = {
}

// display a list of active processes
const ProcessEvents = ({ processes }: Props) => {
const ProcessMessages = ({ processes }: Props) => {
if (!processes.length) {
return null
}
return (
<div css={styles.container}>
{processes.map(process => (
<AlifdMessage key={process.title} type="loading" size="medium" title={process.title}>
<Message key={process.title} type="loading" size="medium" title={process.title}>
{process.description}
</AlifdMessage>
</Message>
))}
</div>
)
}

export default ProcessEvents
export default ProcessMessages
4 changes: 2 additions & 2 deletions web-app/src/containers/Tutorial/LevelPage/Level.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as G from 'typings/graphql'
import { css, jsx } from '@emotion/core'
import Button from '../../../components/Button'
import Markdown from '../../../components/Markdown'
import ProcessEvents from '../../../components/ProcessEvents'
import ProcessMessages from '../../../components/ProcessMessages'
import Step from './Step'

const styles = {
Expand Down Expand Up @@ -109,7 +109,7 @@ const Level = ({ level, onContinue, onLoadSolution, processes }: Props) => {

{processes.length > 0 && (
<div css={styles.processes}>
<ProcessEvents processes={processes} />
<ProcessMessages processes={processes} />
</div>
)}

Expand Down
4 changes: 2 additions & 2 deletions web-app/stories/Commands.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { storiesOf } from '@storybook/react'
import React from 'react'
import ProcessEvents from '../src/components/ProcessEvents'
import ProcessMessages from '../src/components/ProcessMessages'
import SideBarDecorator from './utils/SideBarDecorator'

const styles = {
Expand All @@ -13,7 +13,7 @@ const styles = {
storiesOf('Components', module)
.addDecorator(SideBarDecorator)
.add('Processes', () => (
<ProcessEvents
<ProcessMessages
processes={[
{
title: 'npm install',
Expand Down
22 changes: 22 additions & 0 deletions web-app/stories/TestNotify.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { storiesOf } from '@storybook/react'
import React from 'react'
import { css, jsx } from '@emotion/core'
import SideBarDecorator from './utils/SideBarDecorator'
import Message from '../src/components/Message'

const styles = {
container: {
display: 'flex' as 'flex',
flexDirection: 'column' as 'column',
},
}

storiesOf('Test Notification', module)
.addDecorator(SideBarDecorator)
.add('Toast', () => {
return (
<div css={styles.container}>
<Message title="Test" closeable />
</div>
)
})