-
Notifications
You must be signed in to change notification settings - Fork 1
Make improvements to experimental endpoint based on existing functionality #114
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7394930
move StretchLengths file to Experimental
alenia b08df61
experimental endpoint now shows component named Experimental, add a f…
alenia 543e1f3
add information about number of color sequences displayed
alenia 8a4e0b8
add color sequence length to label
alenia e0414bf
make default stagger type normal
alenia a35adce
slight wording adjustment
alenia 2fd8bfb
show tooltip on dropdown input
alenia 1c2fd92
lint
alenia dbaa3a4
refactor StaggerType into types.ts
alenia 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
8 changes: 4 additions & 4 deletions
8
src/projects/StretchLengths.test.tsx → src/projects/Experimental.test.tsx
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,90 @@ | ||
| import SwatchWithForm from '../SwatchWithForm'; | ||
| import { StitchPattern, Color, StaggerType } from '../types' | ||
| import { useSwatchConfigStateFromURLParams, useEffectToUpdateURLParamsFromSwatchConfig } from '../URLSwatchParams'; | ||
| import { useState } from "react"; | ||
| import ColorSequenceInfo from '../ColorSequenceInfo' | ||
| import DropdownInput from '../inputs/Dropdown'; | ||
| import { totalColorSequenceLength } from '../colorSequenceHelpers' | ||
|
|
||
| const red = "#ff001d" as Color; | ||
| const cream = "#fcf7eb" as Color; | ||
| const ltblue = "#8dd0f2" as Color; | ||
| const navy = "#0e0e66" as Color; | ||
|
|
||
| function Experimental() { | ||
| const defaultSwatchConfig = { | ||
| colorSequence: [ | ||
| {color: navy, length: 3}, | ||
| {color: red, length: 3}, | ||
| {color: navy, length: 3}, | ||
| {color: ltblue, length: 2}, | ||
| {color: cream, length: 5}, | ||
| {color: ltblue, length: 2}, | ||
| ], | ||
| stitchesPerRow: 18, //Note: explicitly ok not saving zero from search params here | ||
| numberOfRows: 40, //Note: explicitly ok not pulling zero from search params here | ||
| colorShift: 0, | ||
| staggerLengths: false, | ||
| stitchPattern: StitchPattern.moss, | ||
| } | ||
|
|
||
| const { swatchConfig, setSwatchConfig, setSearchParams} = useSwatchConfigStateFromURLParams(defaultSwatchConfig); | ||
|
|
||
| const [staggerType, setStaggerType] = useState('normal' as StaggerType) | ||
|
|
||
| const setStaggerTypeFromDropdown = (newStaggerType: string) => { | ||
| setStaggerType(newStaggerType as StaggerType) | ||
| } | ||
|
|
||
| useEffectToUpdateURLParamsFromSwatchConfig(swatchConfig, setSearchParams) | ||
|
|
||
| const numStitches = swatchConfig.stitchesPerRow * swatchConfig.numberOfRows | ||
| const numColorSequences = numStitches/totalColorSequenceLength(swatchConfig.colorSequence) | ||
|
|
||
| return ( | ||
| <div> | ||
| <p>This is an experimental page. It might change at anytime and URLs can break.</p> | ||
| <p>Here are the current features:</p> | ||
| <ul> | ||
| <li>there is a button to double your colors that makes a copy of all the colors</li> | ||
| <li>there’s more info about the colors you see</li> | ||
| <li>you can change stagger type (not saved on url)</li> | ||
| </ul> | ||
| <p>If you don't know what I'm talking about use the <a href='/'>main app.</a></p> | ||
| <form | ||
| onSubmit={(e) => { | ||
| e.preventDefault(); | ||
| }} | ||
| className='wide-first-column' | ||
| > | ||
| <fieldset> | ||
| <ColorSequenceInfo colorSequence={swatchConfig.colorSequence} colorShift={swatchConfig.colorShift}/> | ||
| <p>In this swatch:</p> | ||
| <pre>Number of stitches/clusters displayed (might be wrong with a stagger type): {numStitches}</pre> | ||
| <pre>Number of {swatchConfig.colorSequence.length}-color color sequences displayed: {numColorSequences.toFixed(1)}</pre> | ||
| <DropdownInput | ||
| label="Row alternating technique:" | ||
| name="staggerType" | ||
| title="This changes how the piece behaves at the boundary between the end of an even row and beginning of an odd row when the checkbox is checked" | ||
| value={staggerType} | ||
| setValue={setStaggerTypeFromDropdown} | ||
| withTooltip={true} | ||
| items={[ | ||
| {label: 'Display odd rows and even rows with different lengths', value: 'normal'}, | ||
| {label: 'Color stretching (increasing tension)', value: 'colorStretched'}, | ||
| {label: 'Color swallowing (loosening tension)', value: 'colorSwallowed'}, | ||
| ]} | ||
| /> | ||
| </fieldset> | ||
| </form> | ||
| <SwatchWithForm | ||
| swatchConfig={swatchConfig} | ||
| setSwatchConfig={setSwatchConfig} | ||
| staggerType={staggerType} | ||
| showExperimentalFeatures={true} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default Experimental; | ||
This file was deleted.
Oops, something went wrong.
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
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.