Skip to content

Commit 1103fcc

Browse files
committed
feat(documentation, organisms): add organisms package to repo and documentation
1 parent 414f74b commit 1103fcc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1669
-29
lines changed

packages/documentation/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@offcourse/atoms": "^1.1.0",
7-
"@offcourse/molecules": "^1.0.0",
6+
"@offcourse/atoms": "^0.0.0-semantically-released",
7+
"@offcourse/molecules": "^0.0.0-semantically-released",
8+
"@offcourse/organisms": "^0.0.0-semantically-released",
89
"catalog": "^3.5.3",
910
"react": "^16.4.0",
1011
"react-dom": "^16.4.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
```react|dark
2+
state: { isOpen: false }
3+
---
4+
const toggle = () => setState({isOpen: !state.isOpen });
5+
const links = [
6+
{ onClick: toggle, title: "Create Course", level: 1 },
7+
{ href: "/bla", title: "Admin", level: 3 },
8+
{ href: "/bla", title: "Profile", level: 2 },
9+
{ onClick: toggle, title: "Sign Out", level: 2 }
10+
];
11+
12+
13+
<div style={{height: "200px"}}>
14+
<AppShell position="absolute" onLogoClick={toggle} toggleSidebar={toggle} isSidebarOpen={state.isOpen} links={links}>
15+
<h1 style={{color: "white", paddingLeft: "1rem"}}>This is the area where the content is rendered...</h1>
16+
</AppShell>
17+
</div>
18+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
```react
2+
const handler = message => alert(JSON.stringify(message, null, 2));
3+
4+
<Auth signIn={handler} initialUserName="yeehaa" signUp={handler} resetPassword={handler} />
5+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
CourseCard Component.
2+
3+
```react|span-6
4+
const course = {
5+
courseId: "abc",
6+
goal: "Learn This",
7+
curator: "Offcourse",
8+
courseUrl: "/yeehaa",
9+
profileUrl: `/curator/yeehaa`,
10+
checkpoints: [
11+
{
12+
checkpointId: "a",
13+
task: `Gentrify adipisicing fanny pack pabst, health goth excepteur ut sunt swag quo`,
14+
resourceUrl: "/"
15+
},
16+
{
17+
checkpointId: "b",
18+
task: "Do That",
19+
completed: true,
20+
resourceUrl: "/"
21+
},
22+
{
23+
checkpointId: "c",
24+
task: "Do More",
25+
resourceUrl: "/"
26+
}
27+
],
28+
tags: ["tic", "tac", "toe"],
29+
description: `Gentrify adipisicing fanny pack pabst, health goth excepteur ut sunt swag qui plaid tumeric letterpress. Wolf gentrify live-edge 8-bit. Af ut thundercats locavore williamsburg, blue bottle man braid viral`
30+
};
31+
<CourseCard course={course} />
32+
```
33+
34+
Pass an onCheckpointToggle callback to make it trackable
35+
36+
```react|span-6
37+
const course = {
38+
courseId: "abc",
39+
goal: "Learn This",
40+
curator: "Offcourse",
41+
courseUrl: "/yeehaa",
42+
profileUrl: `/curator/yeehaa`,
43+
checkpoints: [
44+
{
45+
checkpointId: "a",
46+
task: `Gentrify adipisicing fanny pack pabst, health goth excepteur ut sunt swag quo`,
47+
resourceUrl: "/"
48+
},
49+
{
50+
checkpointId: "b",
51+
task: "Do That",
52+
completed: true,
53+
resourceUrl: "/"
54+
},
55+
{
56+
checkpointId: "c",
57+
task: "Do More",
58+
resourceUrl: "/"
59+
}
60+
],
61+
tags: ["tic", "tac", "toe"],
62+
description: `Gentrify adipisicing fanny pack pabst, health goth excepteur ut sunt swag qui plaid tumeric letterpress. Wolf gentrify live-edge 8-bit. Af ut thundercats locavore williamsburg, blue bottle man braid viral`
63+
};
64+
<CourseCard onCheckpointToggle={console.log} course={course} />
65+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
```react|span-4
2+
state: { errors: { general: "you seem to have misspelled something..."} }
3+
---
4+
const submitHandler = (values, actions) => {
5+
setState(
6+
{
7+
errors: {
8+
general: "you seem to have misspelled something..."
9+
}
10+
},
11+
actions.setSubmitting(false)
12+
);
13+
};
14+
15+
const handler = () => alert("Everyting is Erased!!!!");
16+
17+
<CourseForm
18+
errors={state.errors}
19+
onSubmit={submitHandler}
20+
onCancel={handler}
21+
/>
22+
```
23+
24+
```react|span-4
25+
state: { errors: {} }
26+
---
27+
const submitHandler = (values, actions) => {
28+
setState(
29+
{
30+
errors: {
31+
general: "you seem to have misspelled something..."
32+
}
33+
},
34+
actions.setSubmitting(false)
35+
);
36+
};
37+
38+
const course = {
39+
courseId: "abc",
40+
goal: "Learn This",
41+
checkpoints: [
42+
{
43+
checkpointId: "a",
44+
task: "Do This",
45+
resourceUrl: "https://github.com/jaredpalmer/formik"
46+
},
47+
{
48+
checkpointId: "b",
49+
task: "Do That",
50+
resourceUrl: "https://github.com/jquense/yup"
51+
},
52+
{
53+
checkpointId: "c",
54+
completed: true,
55+
task: "Do More",
56+
resourceUrl: "https://semantic-ui.com/collections/form.html"
57+
}
58+
],
59+
description: `Gentrify adipisicing fanny pack pabst, health goth excepteur ut sunt swag qui plaid tumeric letterpress. Wolf gentrify live-edge 8-bit. Af ut thundercats locavore williamsburg, blue bottle man braid viral`
60+
};
61+
62+
const handler = () => alert("Everyting is Erased!!!!");
63+
64+
<CourseForm
65+
mode="edit"
66+
course={course}
67+
errors={state.errors}
68+
onSubmit={submitHandler}
69+
onCancel={handler}
70+
/>
71+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
Basic Form
2+
3+
```react|span-4
4+
const onSubmit = (values, actions) => {
5+
alert(JSON.stringify(values, null, 2));
6+
actions.setSubmitting(false)
7+
};
8+
9+
const onCancel = () => alert("Everyting is Erased!!!!");
10+
11+
const yup = Form.yup;
12+
13+
class Model {
14+
static schemata = {
15+
normal: yup.object().shape({
16+
testField: yup.string().min(5).max(8).required()
17+
})
18+
};
19+
20+
21+
constructor({ testField = ""}){
22+
this.testField = testField;
23+
}
24+
}
25+
26+
const values = { testField: "abc"}
27+
28+
const Field = Form.Field;
29+
<Form
30+
values={values}
31+
Model={Model}
32+
title="Test Form"
33+
onSubmit={onSubmit}
34+
onCancel={onCancel}
35+
>
36+
<Field title="Test Field" name="testField" placeholder="Test" />
37+
</Form>
38+
```
39+
40+
Pimped Out Form
41+
42+
```react|span-4
43+
state: { errors: {}}
44+
---
45+
46+
const errors = {general: "you seem to have misspelled something..."};
47+
const testItems1 = [{task: "aaaa", resourceUrl: "bbb"}, {task: "", resourceUrl: ""}];
48+
const testItems2 = ["aaaaa", "bbbb"];
49+
50+
const onSubmit = (values, actions) => {
51+
alert(JSON.stringify(values, null, 2));
52+
setState({errors}),
53+
actions.setSubmitting(true)
54+
};
55+
56+
57+
const onCancel = () => alert("Everyting is Erased!!!!");
58+
const values = {
59+
testField: "ab",
60+
testItems: testItems2
61+
};
62+
63+
const buttons = {
64+
warning: {
65+
title: "Maybe...",
66+
variant: "warning",
67+
onClick: () => confirm("are you sure"),
68+
size: "small"
69+
},
70+
cancel: {
71+
title: "HELL NO",
72+
size: "medium"
73+
},
74+
submit: {
75+
title: "Okay",
76+
size: "small"
77+
}
78+
};
79+
80+
const linkData = [
81+
{ onClick: onCancel, title: "Go Somewhere Else" },
82+
{ onClick: onCancel, title: "Go Someplace Other" }
83+
];
84+
85+
const yup = Form.yup;
86+
class Model {
87+
static schemata = {
88+
normal: yup.object().shape({
89+
testField: yup.string().min(5).max(8).required(),
90+
testItems: yup.array().of(yup.string().min(3)).min(2).max(3).required()
91+
})
92+
};
93+
94+
constructor({ testField = "", testItems = [""]}){
95+
this.testField = testField;
96+
this.testItems = testItems;
97+
}
98+
}
99+
100+
const Field = Form.Field;
101+
const FieldList = Form.FieldList;
102+
<Form
103+
values={values}
104+
Model={Model}
105+
errors={state.errors}
106+
title="Test Form"
107+
links={linkData}
108+
buttons={buttons}
109+
onSubmit={onSubmit}
110+
onCancel={onCancel}
111+
>
112+
<Field title="Test Field" name="testField" placeholder="Test" />
113+
<FieldList title="Test Items" name="testItems"/>
114+
</Form>
115+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
```react|span-4
2+
const errors = {};
3+
const userName = "";
4+
const handler = () => alert("Done!");
5+
6+
<PasswordRetrievalForm
7+
errors={errors}
8+
userName={userName}
9+
onSubmit={handler}
10+
onCancel={handler}
11+
onRequestSignIn={handler}
12+
/>
13+
```
14+
15+
```react|span-4
16+
const confirmMode = true;
17+
const errors = {};
18+
const userName = "";
19+
const handler = () => alert("Done!");
20+
21+
<PasswordRetrievalForm
22+
mode="confirm"
23+
errors={errors}
24+
userName={userName}
25+
onSubmit={handler}
26+
onCancel={handler}
27+
onRequestSignIn={handler}
28+
/>
29+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```react|span-4
2+
const handler = () => alert("Done!");
3+
const errors = {};
4+
5+
<SignInForm
6+
errors={errors}
7+
onCancel={handler}
8+
onSubmit={handler}
9+
onRequestSignIn={handler}
10+
/>
11+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```react|span-4
2+
const errors = {};
3+
const userName = "";
4+
const handler = () => alert("Done!");
5+
6+
<SignUpForm
7+
errors={errors}
8+
userName={userName}
9+
onSubmit={handler}
10+
onRequestSignIn={handler}
11+
/>
12+
```
13+
14+
```react|span-4
15+
const errors = {};
16+
const userName = "";
17+
const handler = () => alert("Done!");
18+
19+
<SignUpForm
20+
mode="confirm"
21+
errors={errors}
22+
userName={userName}
23+
onSubmit={handler}
24+
onRequestSignIn={handler}
25+
/>
26+
```

packages/documentation/src/App.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Component } from "react";
22
import * as atoms from "@offcourse/atoms";
33
import * as molecules from "@offcourse/molecules";
4+
import * as organisms from "@offcourse/organisms";
45
import { Catalog, pageLoader } from "catalog";
56
import { offcourse } from "./themes";
67

@@ -68,6 +69,13 @@ class App extends Component {
6869
name: "molecules",
6970
blocks: molecules
7071
})
72+
},
73+
{
74+
title: "Organisms",
75+
pages: createPages({
76+
name: "organisms",
77+
blocks: organisms
78+
})
7179
}
7280
]}
7381
/>

packages/organisms/.babelrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"modules": false
5+
}],
6+
"stage-0",
7+
"react"
8+
],
9+
"plugins": [
10+
"external-helpers"
11+
]
12+
}

0 commit comments

Comments
 (0)