-
Notifications
You must be signed in to change notification settings - Fork 6
"Add settings page and controls" #2402
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
Merged
jackkeller
merged 12 commits into
develop
from
feature-2356/add-application-settings-page
May 20, 2024
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
48bf2de
adds blank settings page
jackkeller e9a5b73
adds logo upload settings section
jackkeller dfc964a
WIP: env acting up again
jackkeller c8249d7
chore: formatting
jackkeller a838982
ordering
jackkeller 58b8a4b
basic settings types, adds JSDocs
jackkeller 132e984
sets up basic implementation in array of objects to simulate possibly…
jackkeller f8c6366
some styling updates
jackkeller 0d665d5
updates file setting control a little further, updates some css
jackkeller 97c1b13
adds stories for settings controls, brings in ladle to use instead of…
jackkeller e1cdcde
pulls repeated string logic into a helper
jackkeller a8d5827
removes hardcoded true from boolean example
jackkeller 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 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
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
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
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
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,5 @@ | ||
| export { default as SettingsBoolean } from './types/boolean.jsx'; | ||
| export { default as SettingsColor } from './types/color.jsx'; | ||
| export { default as SettingsFile } from './types/file.jsx'; | ||
| export { default as SettingsNumber } from './types/number.jsx'; | ||
| export { default as SettingsString } from './types/string.jsx'; |
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,38 @@ | ||
| import React from 'react'; | ||
| import { Switch, Typography } from '@mui/material'; | ||
| import { createLabelId } from '../../../helpers/strings.js'; | ||
|
|
||
| /** | ||
| * A component for rendering a boolean input field in the settings. | ||
| * | ||
| * @component | ||
| * @param {Object} props | ||
| * @param {string} props.label - The label for the settings component. | ||
| * @param {string} [props.description] - The description for the settings component. | ||
| * @param {boolean} props.value - The value of the settings component. | ||
| * @param {Function} props.handleChange - The function to handle the change event of the settings component. | ||
| * @returns {JSX.Element} The rendered boolean settings component. | ||
| */ | ||
| const SettingsBoolean = ({ label, description, value, handleChange }) => { | ||
| const labelId = createLabelId(label); | ||
|
|
||
| return ( | ||
| <div className="settings-type"> | ||
| <label htmlFor={labelId}> | ||
| <Typography variant="h5" gutterBottom> | ||
| {label} | ||
| </Typography> | ||
| </label> | ||
| {description ?? <p>{description}</p>} | ||
| <Switch | ||
| id={labelId} | ||
| className="settings-control" | ||
| type="checkbox" | ||
| checked={value} | ||
| onChange={handleChange} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SettingsBoolean; |
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,26 @@ | ||
| import React from 'react'; | ||
| import SettingsBoolean from './boolean'; | ||
| import '../../../pages/SettingsPage.css'; | ||
|
|
||
| export default { | ||
| component: SettingsBoolean, | ||
| title: 'Check Ins/Settings', | ||
| decorators: [ | ||
| SettingsBoolean => ( | ||
| <div className="settings-page"> | ||
| <SettingsBoolean /> | ||
| </div> | ||
| ) | ||
| ] | ||
| }; | ||
|
|
||
| const Template = args => { | ||
| return <SettingsBoolean {...args} />; | ||
| }; | ||
|
|
||
| export const Boolean = Template.bind({}); | ||
| Boolean.args = { | ||
| label: 'Boolean Control', | ||
| description: 'A control to hold a boolean value', | ||
| handleChange: event => console.log(`BOOLEAN ${event.target.checked}`) | ||
| }; |
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,38 @@ | ||
| import React from 'react'; | ||
| import { Typography } from '@mui/material'; | ||
| import { createLabelId } from '../../../helpers/strings.js'; | ||
|
|
||
| /** | ||
| * A component for rendering a color picker field in the settings. | ||
| * | ||
| * @component | ||
| * @param {Object} props | ||
| * @param {string} props.label - The label for the setting. | ||
| * @param {string} [props.description] - The description for the setting (optional). | ||
| * @param {string} props.value - The current value of the setting. | ||
| * @param {function} props.handleChange - The function to handle changes to the setting value (optional). | ||
| * @returns {JSX.Element} The rendered component. | ||
| */ | ||
| const SettingsColor = ({ label, description, value, handleChange }) => { | ||
| const labelId = createLabelId(label); | ||
|
|
||
| return ( | ||
| <div className="settings-type"> | ||
| <label htmlFor={labelId}> | ||
| <Typography variant="h5" gutterBottom> | ||
| {label} | ||
| </Typography> | ||
| </label> | ||
| {description ?? <p>{description}</p>} | ||
| <input | ||
| id={labelId} | ||
| className="settings-control" | ||
| type="color" | ||
| value={value} | ||
| onChange={handleChange} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SettingsColor; |
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,27 @@ | ||
| import React from 'react'; | ||
| import SettingsColor from './color'; | ||
| import '../../../pages/SettingsPage.css'; | ||
|
|
||
| export default { | ||
| component: SettingsColor, | ||
| title: 'Check Ins/Settings', | ||
| decorators: [ | ||
| SettingsColor => ( | ||
| <div className="settings-page"> | ||
| <SettingsColor /> | ||
| </div> | ||
| ) | ||
| ] | ||
| }; | ||
|
|
||
| const Template = args => { | ||
| return <SettingsColor {...args} />; | ||
| }; | ||
|
|
||
| export const Color = Template.bind({}); | ||
| Color.args = { | ||
| label: 'Color Control', | ||
| description: 'A control to hold a color value', | ||
| value: '#2c519e', | ||
| handleChange: event => console.log(`COLOR: ${event.target.value}`) | ||
| }; |
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,54 @@ | ||
| import React from 'react'; | ||
| import { Button, Typography } from '@mui/material'; | ||
| import { AddCircle } from '@mui/icons-material'; | ||
| import { createLabelId } from '../../../helpers/strings.js'; | ||
|
|
||
| /** | ||
| * A component for handling file settings. | ||
| * | ||
| * @component | ||
| * @param {Object} props - The component props. | ||
| * @param {string} props.label - The label of the file settings. | ||
| * @param {string} [props.description] - The description of the file settings. | ||
| * @param {Object} props.fileRef - The reference to the file input element. | ||
| * @param {Function} props.handleFile - The function to handle file upload. | ||
| * @returns {JSX.Element} The rendered component. | ||
| */ | ||
| const SettingsFile = ({ fileRef, handleFile, label, description }) => { | ||
| const labelId = createLabelId(label); | ||
|
|
||
| const handleClick = event => { | ||
| fileRef.current.click(); | ||
| }; | ||
|
|
||
| const handleChange = event => { | ||
| const fileUploaded = event.target.files[0]; | ||
| handleFile(fileUploaded); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="settings-type"> | ||
| <label htmlFor={labelId}> | ||
| <Typography variant="h5" gutterBottom> | ||
| {label} | ||
| </Typography> | ||
| </label> | ||
| {description ?? <p>{description}</p>} | ||
| <div className="settings-control"> | ||
| <Button onClick={handleClick}> | ||
| <AddCircle /> | ||
| Upload | ||
| </Button> | ||
| <input | ||
| id={labelId} | ||
| type="file" | ||
| ref={fileRef} | ||
| onChange={handleChange} | ||
| className="hidden" | ||
| /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SettingsFile; | ||
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,29 @@ | ||
| import React from 'react'; | ||
| import SettingsFile from './file'; | ||
| import '../../../pages/SettingsPage.css'; | ||
|
|
||
| const fileRef = null; | ||
|
|
||
| export default { | ||
| component: SettingsFile, | ||
| title: 'Check Ins/Settings', | ||
| decorators: [ | ||
| SettingsFile => ( | ||
| <div className="settings-page"> | ||
| <SettingsFile /> | ||
| </div> | ||
| ) | ||
| ] | ||
| }; | ||
|
|
||
| const Template = args => { | ||
| return <SettingsFile {...args} />; | ||
| }; | ||
|
|
||
| export const File = Template.bind({}); | ||
| File.args = { | ||
| label: 'File Control', | ||
| description: 'A control to upload a File', | ||
| fileRef, | ||
| handleFile: event => console.log(`File: ${event.target.value}`) | ||
| }; |
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,38 @@ | ||
| import React from 'react'; | ||
| import { Input, Typography } from '@mui/material'; | ||
| import { createLabelId } from '../../../helpers/strings.js'; | ||
|
|
||
| /** | ||
| * A component for rendering a number input field in the settings. | ||
| * | ||
| * @component | ||
| * @param {Object} props | ||
| * @param {string} props.label - The label for the number input field. | ||
| * @param {string} [props.description] - The description for the input field (optional). | ||
| * @param {number} props.value - The current value of the number input field. | ||
| * @param {function} props.handleChange - The callback function to handle value changes. | ||
| * @returns {JSX.Element} - The rendered component. | ||
| */ | ||
| const SettingsNumber = ({ label, description, value, handleChange }) => { | ||
| const labelId = createLabelId(label); | ||
|
|
||
| return ( | ||
| <div className="settings-type"> | ||
| <label htmlFor={labelId}> | ||
| <Typography variant="h5" gutterBottom> | ||
| {label} | ||
| </Typography> | ||
| </label> | ||
| {description ?? <p>{description}</p>} | ||
| <Input | ||
| id={labelId} | ||
| className="settings-control" | ||
| type="number" | ||
| value={value} | ||
| onChange={handleChange} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SettingsNumber; |
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,25 @@ | ||
| import React from 'react'; | ||
| import SettingsNumber from './number'; | ||
| import '../../../pages/SettingsPage.css'; | ||
|
|
||
| export default { | ||
| component: SettingsNumber, | ||
| title: 'Check Ins/Settings', | ||
| decorators: [ | ||
| SettingsNumber => ( | ||
| <div className="settings-page"> | ||
| <SettingsNumber /> | ||
| </div> | ||
| ) | ||
| ] | ||
| }; | ||
|
|
||
| const Template = args => { | ||
| return <SettingsNumber {...args} />; | ||
| }; | ||
|
|
||
| export const Number = Template.bind({}); | ||
| Number.args = { | ||
| label: 'Number Control', | ||
| description: 'A control to hold a numerical value' | ||
| }; |
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,46 @@ | ||
| import React from 'react'; | ||
| import { Input, Typography } from '@mui/material'; | ||
| import { createLabelId } from '../../../helpers/strings.js'; | ||
|
|
||
| /** | ||
| * A component for rendering a number input field in the settings. | ||
| * | ||
| * @component | ||
| * @param {Object} props | ||
| * @param {string} props.label - The label for the input field. | ||
| * @param {string} [props.description] - The description for the input field (optional). | ||
| * @param {string} props.value - The current value of the input field. | ||
| * @param {string} [props.placeholder] - The placeholder text for the input field (optional). | ||
| * @param {function} props.handleChange - The function to handle input field changes. | ||
| * @returns {JSX.Element} - The rendered component. | ||
| */ | ||
| const SettingsString = ({ | ||
| label, | ||
| description, | ||
| value, | ||
| placeholder, | ||
| handleChange | ||
| }) => { | ||
| const labelId = createLabelId(label); | ||
|
|
||
| return ( | ||
| <div className="settings-type"> | ||
| <label htmlFor={labelId}> | ||
| <Typography variant="h5" gutterBottom> | ||
| {label} | ||
| </Typography> | ||
| </label> | ||
| {description ?? <p>{description}</p>} | ||
| <Input | ||
| id={labelId} | ||
| className="settings-control" | ||
| type="text" | ||
| value={value} | ||
| placeholder={placeholder ?? `Enter ${label}`} | ||
| onChange={handleChange} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SettingsString; |
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.
Uh oh!
There was an error while loading. Please reload this page.