- Notifications
You must be signed in to change notification settings - Fork39
Load/tutorial from url#178
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
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
47 changes: 22 additions & 25 deletionsweb-app/src/containers/SelectTutorial/SelectTutorialForm.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletionsweb-app/src/containers/SelectTutorial/forms/TutorialSelect.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as React from 'react' | ||
import useFetch from '../../../services/hooks/useFetch' | ||
import { TUTORIAL_LIST_URL } from '../../../environment' | ||
import { Form, Select } from '@alifd/next' | ||
const FormItem = Form.Item | ||
const Option = Select.Option | ||
type TutorialList = Array<{ id: string; title: string; configUrl: string }> | ||
interface Props { | ||
onTutorialLoad(url: string): void | ||
} | ||
const TutorialSelect = (props: Props) => { | ||
// load tutorial from a path to a tutorial list json | ||
const { data, error, loading } = useFetch<TutorialList>(TUTORIAL_LIST_URL) | ||
// TODO: display errors | ||
const selectState = loading ? 'loading' : error || !data ? 'error' : undefined | ||
return ( | ||
<Form style={{ maxWidth: '500px' }}> | ||
<FormItem label="Select Tutorial:"> | ||
<Select | ||
onChange={props.onTutorialLoad} | ||
style={{ width: '100%' }} | ||
placeholder="Tutorials..." | ||
state={selectState} | ||
> | ||
{data && | ||
data.map((tutorial) => ( | ||
<Option key={tutorial.id} value={tutorial.configUrl}> | ||
{tutorial.title} | ||
</Option> | ||
))} | ||
</Select> | ||
</FormItem> | ||
</Form> | ||
) | ||
} | ||
export default TutorialSelect |
39 changes: 39 additions & 0 deletionsweb-app/src/containers/SelectTutorial/forms/TutorialUrl.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as React from 'react' | ||
import { Button, Form, Radio, Input } from '@alifd/next' | ||
const FormItem = Form.Item | ||
interface Props { | ||
defaultUrl: string | ||
onTutorialLoad(url: string): void | ||
} | ||
const TutorialUrl = (props: Props) => { | ||
const [url, setUrl] = React.useState(props.defaultUrl) | ||
const onSubmit = (e: any) => { | ||
e.preventDefault() | ||
console.log('tutorial url', url) | ||
props.onTutorialLoad(url) | ||
} | ||
return ( | ||
// @ts-ignore seems to be an onSubmit event ts error in lib | ||
<Form style={{ maxWidth: '600px' }} onSubmit={onSubmit}> | ||
<FormItem label="URL path to coderoad config.json"> | ||
<Input | ||
size="large" | ||
placeholder="https://raw.githubusercontent.com/coderoad/fcc-learn-npm/master/coderoad-config.json" | ||
defaultValue={props.defaultUrl} | ||
onChange={setUrl} | ||
aria-label="input url path to coderoad config.json" | ||
/> | ||
</FormItem> | ||
<Button htmlType="submit" type="primary"> | ||
Load | ||
</Button>{' '} | ||
| ||
</Form> | ||
) | ||
} | ||
export default TutorialUrl |
10 changes: 8 additions & 2 deletionsweb-app/src/containers/SelectTutorial/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletionsweb-app/src/environment.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletionsweb-app/stories/API.stories.tsx
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
19 changes: 0 additions & 19 deletionsweb-app/stories/GitHubFetch.stories.tsx
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
99 changes: 57 additions & 42 deletionsweb-app/stories/Overview.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,69 @@ | ||
import * as TT from '../../typings/tutorial' | ||
import { linkTo } from '@storybook/addon-links' | ||
import { action } from '@storybook/addon-actions' | ||
import { storiesOf } from '@storybook/react' | ||
import React from 'react' | ||
import OverViewPage from '../src/components/TutorialOverview' | ||
import SideBarDecorator from './utils/SideBarDecorator' | ||
storiesOf('Overview', module) | ||
.addDecorator(SideBarDecorator) | ||
.add('OverView Page', () => { | ||
const tutorial: TT.Tutorial = { | ||
id: '1', | ||
version: '0.1.0', | ||
config: { | ||
testRunner: { command: '' }, | ||
repo: { uri: '', branch: 'master' }, | ||
}, | ||
summary: { | ||
title: 'Manage NPM package.json', | ||
description: 'Learn to use the package manager at the core of JavaScript projects.', | ||
}, | ||
levels: [ | ||
{ | ||
id: 'L1', | ||
title: 'The First Level', | ||
summary: 'A Summary of the first level', | ||
content: '', | ||
steps: [], | ||
}, | ||
{ | ||
id: 'L2', | ||
title: 'The Second Level', | ||
summary: 'A Summary of the second level', | ||
content: '', | ||
steps: [], | ||
}, | ||
{ | ||
id: 'L3', | ||
title: 'The Third Level', | ||
summary: 'A Summary of the third level', | ||
content: '', | ||
steps: [], | ||
}, | ||
{ | ||
id: 'L4', | ||
title: 'The Fourth Level', | ||
summary: 'A Summary of the fourth level', | ||
content: '', | ||
steps: [], | ||
}, | ||
{ | ||
id: 'L5', | ||
title: 'The Fifth Level', | ||
summary: 'A Summary of the fifth level', | ||
content: '', | ||
steps: [], | ||
}, | ||
{ | ||
id: 'L6', | ||
title: 'The Sixth Level', | ||
summary: 'A Summary of the sixth level', | ||
content: '', | ||
steps: [], | ||
}, | ||
], | ||
} | ||
return <OverViewPage tutorial={tutorial} onClear={action('clear')} onNext={linkTo('Tutorial SideBar', 'Level')} /> | ||
}) |
16 changes: 2 additions & 14 deletionsweb-app/stories/SelectTutorial.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.