-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e09bb7
commit 0601119
Showing
14 changed files
with
531 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,4 @@ | ||
TODO: not sure how to inject this in an mdx page then | ||
**Had some trouble with this first step?** | ||
|
||
[Join us on Slack and ask your questions directly](http://slack.vulcanjs.org/) |
This file contains 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,61 @@ | ||
import { | ||
Box, | ||
Divider, | ||
List, | ||
ListItem, | ||
ListItemButton, | ||
ListSubheader, | ||
Typography, | ||
} from "@mui/material"; | ||
import { ReactNode, useState } from "react"; | ||
|
||
export interface MultipleChoiceQuestionProps { | ||
question: string; | ||
answers: Array<string>; | ||
/** idx of the answer in the questions array (only one valid answer per choice) */ | ||
validAnswerIdx: number; | ||
ifOk: ReactNode; | ||
} | ||
export const MultipleChoiceQuestion = ({ | ||
question, | ||
answers, | ||
validAnswerIdx, | ||
ifOk, | ||
}: MultipleChoiceQuestionProps) => { | ||
const [currentAnswer, setCurrentAnswer] = useState<number | undefined>( | ||
undefined | ||
); | ||
return ( | ||
<Box> | ||
<List | ||
subheader={ | ||
<ListSubheader>{question} (click on the right answer)</ListSubheader> | ||
} | ||
> | ||
{answers.map((answer, idx) => { | ||
return ( | ||
<ListItem key={idx}> | ||
<ListItemButton | ||
onClick={() => setCurrentAnswer(idx)} | ||
selected={idx === currentAnswer} | ||
> | ||
{answer} | ||
</ListItemButton> | ||
</ListItem> | ||
); | ||
})} | ||
</List> | ||
{currentAnswer === validAnswerIdx ? ifOk : null} | ||
{currentAnswer && currentAnswer !== validAnswerIdx ? ( | ||
<> | ||
<Typography sx={{ color: "warning.main" }}> | ||
Wrong answer... | ||
</Typography> | ||
<Typography sx={{ color: "secondary.main" }}> | ||
Try another answer to unlock next step! | ||
</Typography> | ||
</> | ||
) : null} | ||
</Box> | ||
); | ||
}; |
This file contains 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
This file contains 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
This file contains 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,59 @@ | ||
/** | ||
* I am a sample model | ||
* Replace me with your own | ||
*/ | ||
import { VulcanDocument } from "@vulcanjs/schema"; | ||
import { | ||
CreateGraphqlModelOptionsServer, | ||
createGraphqlModelServer, | ||
VulcanGraphqlSchemaServer, | ||
} from "@vulcanjs/graphql/server"; | ||
import { createMongooseConnector } from "@vulcanjs/mongo"; | ||
import merge from "lodash/merge"; | ||
import { modelDef as modelDefShared } from "./sampleModel"; | ||
|
||
const schema: VulcanGraphqlSchemaServer = { | ||
_id: { | ||
type: String, | ||
optional: true, | ||
canRead: ["guests"], | ||
}, | ||
userId: { | ||
type: String, | ||
optional: true, | ||
canRead: ["guests"], | ||
}, | ||
createdAt: { | ||
type: Date, | ||
optional: true, | ||
canRead: ["admins"], | ||
onCreate: () => { | ||
return new Date(); | ||
}, | ||
}, | ||
someField: { | ||
type: String, | ||
optional: true, | ||
canRead: ["guests"], | ||
canUpdate: ["admins"], | ||
canCreate: ["owners"], | ||
searchable: true, | ||
}, | ||
}; | ||
|
||
export interface SampleModelType extends VulcanDocument { | ||
someField: string; | ||
} | ||
|
||
const modelDef: CreateGraphqlModelOptionsServer = merge({}, modelDefShared, { | ||
schema, | ||
// add other server only options here | ||
graphql: { | ||
/* ...*/ | ||
}, | ||
}); | ||
export const SampleModel = createGraphqlModelServer(modelDef); | ||
|
||
export const SampleModelConnector = createMongooseConnector<SampleModelType>( | ||
SampleModel | ||
); |
This file contains 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,61 @@ | ||
/** | ||
* I am a sample model | ||
* Replace me with your own | ||
*/ | ||
import { VulcanSchema, VulcanDocument } from "@vulcanjs/schema"; | ||
import { | ||
createGraphqlModel, | ||
CreateGraphqlModelOptionsShared, | ||
} from "@vulcanjs/graphql"; | ||
|
||
const schema: VulcanSchema = { | ||
_id: { | ||
type: String, | ||
optional: true, | ||
canRead: ["guests"], | ||
}, | ||
userId: { | ||
type: String, | ||
optional: true, | ||
canRead: ["guests"], | ||
}, | ||
createdAt: { | ||
type: Date, | ||
optional: true, | ||
canRead: ["admins"], | ||
onCreate: () => { | ||
return new Date(); | ||
}, | ||
}, | ||
someField: { | ||
type: String, | ||
optional: true, | ||
canRead: ["guests"], | ||
canUpdate: ["admins"], | ||
canCreate: ["owners"], | ||
searchable: true, | ||
}, | ||
}; | ||
|
||
export interface SampleModelType extends VulcanDocument { | ||
someField: string; | ||
} | ||
|
||
const name = "Sample"; // Change this value when creating your own model | ||
const typeName = name; | ||
const multiTypeName = "Samples"; // Change this value when creating your own model | ||
export const modelDef: CreateGraphqlModelOptionsShared = { | ||
name: "sample", | ||
schema, | ||
graphql: { | ||
typeName, | ||
multiTypeName, | ||
}, | ||
permissions: { | ||
canCreate: ["member"], | ||
canUpdate: ["owners", "admins"], | ||
canDelete: ["owners", "admins"], | ||
canRead: ["members", "admins"], | ||
}, | ||
}; | ||
export const SampleModel = createGraphqlModel(modelDef); |
This file contains 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
Oops, something went wrong.