-
Notifications
You must be signed in to change notification settings - Fork 26
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
Builds the usability survey page #315
Open
georgeweiler
wants to merge
17
commits into
main
Choose a base branch
from
usability-survey
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5abb9e3
Builds the usability survey page
georgeweiler 8d21a8c
Adds small screen designs
georgeweiler 508de77
Merge branch 'main' of github.com:threshold-network/token-dashboard i…
georgeweiler b84a33e
Adds the NumberButtonSequence component
georgeweiler 9c97e22
Adds stack and size props
georgeweiler 3e7ddcd
Use isActive prop instead of isSelected
georgeweiler e47880b
Merge branch 'main' of github.com:threshold-network/token-dashboard i…
georgeweiler f1d804a
Update table survey to use buttons instead of radios
georgeweiler 2f72073
Merge branch 'likert-scale-buttons' of github.com:threshold-network/t…
georgeweiler ffe4e88
Updates mobile survey to use buttons instead of radios
georgeweiler 55134f5
Merge branch 'main' of github.com:threshold-network/token-dashboard i…
georgeweiler 4e05982
udpate yarn.lock file
georgeweiler b95eafb
Optimize setstate code
georgeweiler 70795b6
updates yarn lock file
georgeweiler 09fd893
Merge branch 'main' of github.com:threshold-network/token-dashboard i…
georgeweiler f2acb95
update a few imports from code review suggestions
georgeweiler 6259a49
Adds yarn.lock file
georgeweiler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { FC } from "react" | ||
import { Button, HStack, StackProps } from "@threshold-network/components" | ||
import { range } from "../utils/range" | ||
import { ButtonProps } from "@chakra-ui/react" | ||
|
||
interface NumberButtonSequenceProps extends StackProps { | ||
numberOfButtons: number | ||
selectedButtonNum?: number | ||
onButtonClick: (n: number) => void | ||
size?: ButtonProps["size"] | ||
} | ||
|
||
const NumberButtonSequence: FC<NumberButtonSequenceProps> = ({ | ||
numberOfButtons, | ||
selectedButtonNum, | ||
onButtonClick, | ||
size, | ||
...props | ||
}) => { | ||
return ( | ||
<HStack spacing={1} {...props}> | ||
{range(numberOfButtons, 1).map((n) => ( | ||
<Button | ||
size={size} | ||
variant="sequence" | ||
isActive={n === selectedButtonNum} | ||
onClick={() => onButtonClick(n)} | ||
> | ||
{n} | ||
</Button> | ||
))} | ||
</HStack> | ||
) | ||
} | ||
|
||
export default NumberButtonSequence |
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,43 @@ | ||
import React, { FC } from "react" | ||
import { BodyMd, LabelSm, Box } from "@threshold-network/components" | ||
import { Row, RowID, RowValue } from "./types" | ||
import NumberButtonSequence from "../../../components/NumberButtonSequence" | ||
import { columns } from "./index" | ||
|
||
const MobileSurvey: FC<{ | ||
rows: Row[] | ||
handleRadioClick: (rowId: RowID, value: RowValue) => void | ||
}> = ({ rows, handleRadioClick }) => { | ||
return ( | ||
<> | ||
<Box display="flex" justifyContent={"space-between"} px={8} py={6}> | ||
<Box> | ||
<LabelSm>Strongly Disagree: 1</LabelSm> | ||
<LabelSm>Disagree: 2</LabelSm> | ||
<LabelSm>Neutral: 3</LabelSm> | ||
</Box> | ||
<Box> | ||
<LabelSm>Agree: 4</LabelSm> | ||
<LabelSm>Strongly Agree: 5</LabelSm> | ||
</Box> | ||
</Box> | ||
{rows.map((row, i) => { | ||
return ( | ||
<Box bg={i % 2 == 0 ? "gray.50" : undefined} px={8} py={6}> | ||
<BodyMd mb={6}>{row.text}</BodyMd> | ||
<NumberButtonSequence | ||
justifyContent="space-between" | ||
numberOfButtons={columns.length} | ||
selectedButtonNum={columns.findIndex((v) => v === row.value) + 1} | ||
onButtonClick={(value) => | ||
handleRadioClick(row.id, columns[value - 1]) | ||
} | ||
/> | ||
</Box> | ||
) | ||
})} | ||
</> | ||
) | ||
} | ||
|
||
export default MobileSurvey |
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,82 @@ | ||
import React, { FC } from "react" | ||
import { | ||
Button, | ||
Table, | ||
Tbody, | ||
Td, | ||
Th, | ||
Thead, | ||
Tr, | ||
useColorModeValue, | ||
} from "@threshold-network/components" | ||
import { Row, RowID, RowValue } from "./types" | ||
import { columns } from "./index" | ||
|
||
const firstColWidth = { | ||
base: "200px", | ||
xl: "300px", | ||
} | ||
|
||
const TableSurvey: FC<{ | ||
rows: Row[] | ||
handleRadioClick: (rowId: RowID, value: RowValue) => void | ||
}> = ({ rows, handleRadioClick }) => { | ||
const s = { | ||
py: 6, | ||
borderColor: useColorModeValue("gray.50", "gray.700"), | ||
} | ||
|
||
return ( | ||
<> | ||
<Table sx={{ tableLayout: "fixed" }}> | ||
<Thead> | ||
<Tr> | ||
<Th {...s} width={firstColWidth}> | ||
Question | ||
</Th> | ||
<Th {...s}>Strongly Disagree</Th> | ||
<Th {...s}>Disagree</Th> | ||
<Th {...s}>Neutral</Th> | ||
<Th {...s}>Agree</Th> | ||
<Th {...s}>Strongly Agree</Th> | ||
</Tr> | ||
</Thead> | ||
</Table> | ||
|
||
{/* TODO: Implement pagination */} | ||
{rows.map((row, i) => { | ||
return ( | ||
<Table sx={{ tableLayout: "fixed" }} key={row.text}> | ||
<Tbody> | ||
<Tr | ||
bg={ | ||
i % 2 == 0 | ||
? useColorModeValue("gray.50", "gray.700") | ||
: undefined | ||
} | ||
{...s} | ||
> | ||
<Td {...s} width={firstColWidth}> | ||
{row.text} | ||
</Td> | ||
{columns.map((value, i) => ( | ||
<Td {...s}> | ||
<Button | ||
variant="sequence" | ||
isActive={row.value === value} | ||
onClick={() => handleRadioClick(row.id, value)} | ||
> | ||
{i + 1} | ||
</Button> | ||
</Td> | ||
))} | ||
</Tr> | ||
</Tbody> | ||
</Table> | ||
) | ||
})} | ||
</> | ||
) | ||
} | ||
|
||
export default TableSurvey |
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,26 @@ | ||
export interface Row { | ||
id: RowID | ||
text: string | ||
value?: RowValue | ||
} | ||
|
||
export enum RowValue { | ||
StrongDisagree = "STRONGLY_DISAGREE", | ||
Disagree = "DISAGREE", | ||
Neutral = "NEUTRAL", | ||
Agree = "AGREE", | ||
StronglyAgree = "STRONGLY_AGREE", | ||
} | ||
|
||
export enum RowID { | ||
FrequentUsage = "FREQUENT_USAGE", | ||
UnnecessarilyComplex = "UNNECESSARILY_COMPLEX", | ||
EasyToUse = "EASY_TO_USE", | ||
NeedTechnicalSupportPerson = "NEED_TECHNICAL_SUPPORT_PERSON", | ||
WellIntegratedFunctions = "WELL_INTEGRATED_FUNCTIONS", | ||
TooMuchInconsistency = "TOO_MUCH_INCONSISTENCY", | ||
QuickToLearn = "QUICK_TO_LEARN", | ||
InconvenientToUse = "INCONVENIENT_TO_USE", | ||
Confident = "CONFIDENT", | ||
HighLearningCurve = "HIGH_LEARNING_CURVE", | ||
} |
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,3 @@ | ||
export const range = (size: number, startAt = 0) => { | ||
return Array.from(Array(size).keys()).map((i) => i + startAt) | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's bump the
components
package- the PR that adds new variant has been merged threshold-network/components#37.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@r-czajkowski doesn't the
development
version cover this case? Is it just ayarn.lock
update we need? or do you suggest we install"@threshold-network/components": "^1.0.0-dev.0",
?