Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

load solution with help balloon#52

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 1 commit intomasterfromfeature/balloon-load-solution
Nov 10, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletionsweb-app/src/components/Button/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,13 +2,15 @@ import * as React from 'react'
import { Button as AlifdButton } from '@alifd/next'

interface Props {
children: string
style?: React.CSSProperties
children: string | React.ReactNode
disabled?: boolean
type?: 'primary' | 'secondary' | 'normal'
onClick(): void
onClick?: () => void
}

const Button = (props: Props) => (
<AlifdButton onClick={props.onClick} type={props.type}>
<AlifdButton onClick={props.onClick} type={props.type} disabled={props.disabled} style={props.style}>
{props.children}
</AlifdButton>
)
Expand Down
15 changes: 15 additions & 0 deletionsweb-app/src/components/Icon/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
import * as React from 'react'
import { Icon as AlifdIcon } from '@alifd/next'

interface Props {
type: string
role?: string
style?: React.CSSProperties
size?: 'xxs' | 'xs' | 'small' | 'medium' | 'large' | 'xl' | 'xxl' | 'xxxl' | 'inherit'
}

const Icon = (props: Props) => {
return <AlifdIcon type={props.type} role={props.role} size={props.size} style={props.style} />
}

export default Icon
55 changes: 55 additions & 0 deletionsweb-app/src/components/StepHelp/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
import * as React from 'react'
import { Balloon } from '@alifd/next'
import Button from '../Button'
import Icon from '../Icon'

const styles = {
iconButton: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
width: 30,
height: 30,
},
balloonTitle: {
marginTop: 0,
},
balloonOptions: {
display: 'flex',
justifyContent: 'center',
},
}

interface Props {
onLoadSolution(): void
}

const StepHelp = (props: Props) => {
// TODO: extract or replace load solution
const [loadedSolution, setLoadedSolution] = React.useState()
const onClickHandler = () => {
if (!loadedSolution) {
setLoadedSolution(true)
props.onLoadSolution()
}
}
const promptLeft = (
<Button style={styles.iconButton}>
<Icon type="prompt" role="button" />
</Button>
)
return (
<Balloon trigger={promptLeft} align="l" alignEdge triggerType="click" style={{ width: 300 }}>
<div>
<h4 style={styles.balloonTitle}>Stuck? Need help?</h4>
<div style={styles.balloonOptions}>
<Button type="secondary" onClick={onClickHandler} disabled={loadedSolution}>
Load Solution
</Button>
</div>
</div>
</Balloon>
)
}

export default StepHelp
46 changes: 22 additions & 24 deletionsweb-app/src/containers/Tutorial/LevelPage/Level/Step/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
import * as React from 'react'
import * as T from 'typings'
import Button from '../../../../../components/Button'
import Checkbox from '../../../../../components/Checkbox'
import Markdown from '../../../../../components/Markdown'
import StepHelp from '../../../../../components/StepHelp'

interface Props {
order: number
Expand All@@ -20,34 +20,32 @@ const styles = {
content: {
margin: 0,
},
options: {
display: 'flex' as 'flex',
flexDirection: 'row' as 'row',
justifyContent: 'flex-end',
alignItems: 'center' as 'center',
padding: '0.5rem',
},
}

const Step = (props: Props) => {
// TODO: extract or replace load solution
const [loadedSolution, setLoadedSolution] = React.useState()
const onClickHandler = () => {
if (!loadedSolution) {
setLoadedSolution(true)
props.onLoadSolution()
}
}
const showLoadSolution = props.status === 'ACTIVE' && !loadedSolution

const showLoadSolution = props.status === 'ACTIVE'
return (
<div style={styles.card}>
<div>
<Checkbox status={props.status} />
</div>
<div>
<Markdown>{props.content || ''}</Markdown>
</div>
<div>
{showLoadSolution && (
<Button type="normal" onClick={onClickHandler}>
Load Solution
</Button>
)}
<div>
<div style={styles.card}>
<div>
<Checkbox status={props.status} />
</div>
<div>
<Markdown>{props.content || ''}</Markdown>
</div>
</div>
{showLoadSolution && (
<div style={styles.options}>
<StepHelp onLoadSolution={props.onLoadSolution} />
</div>
)}
</div>
)
}
Expand Down
6 changes: 4 additions & 2 deletionsweb-app/stories/utils/SideBarDecorator.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,12 @@ import * as React from 'react'

const styles = {
container: {
position: 'relative' as 'relative',
left: '25rem',
position: 'absolute' as 'absolute',
boxSizing: 'border-box' as 'border-box',
borderLeft: '2px solid black',
borderRight: '2px solid black',
width: '100%',
width: '50rem',
height: window.innerHeight,
},
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp