-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from digirati-co-uk/feature/choices
Choice improvements
- Loading branch information
Showing
15 changed files
with
259 additions
and
458 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,50 @@ | ||
import { useCanvasChoices } from '../../hooks/useCanvasChoices'; | ||
import { LocaleString } from '../../utility/i18n-utils'; | ||
|
||
export function ViewChoices() { | ||
const { choices, actions } = useCanvasChoices(); | ||
if (choices.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div> | ||
<h2>Choices</h2> | ||
<ul> | ||
{choices.map(({ canvasId, choice }, index) => ( | ||
<li key={index}> | ||
{canvasId} | ||
{choice.items.map((paintingChoice) => { | ||
return ( | ||
<div> | ||
<LocaleString>{paintingChoice.label}</LocaleString> | ||
<ul> | ||
{paintingChoice.items.map((item) => { | ||
return ( | ||
<li className="p-2 flex gap-2"> | ||
<LocaleString>{item.label}</LocaleString> | ||
<button | ||
className={ | ||
item.selected | ||
? 'bg-green-500 hover:bg-green-700 text-white text-sm py-1 px-3 rounded-full' | ||
: 'bg-gray-500 hover:bg-gray-700 text-white text-sm py-1 px-3 rounded-full' | ||
} | ||
onClick={() => { | ||
actions.makeChoice(item.id, { deselectOthers: true }); | ||
}} | ||
> | ||
Choose | ||
</button> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
</div> | ||
); | ||
})} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.