-
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.
feat: add decoration section to tree page
- Loading branch information
Showing
29 changed files
with
945 additions
and
141 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
2 changes: 1 addition & 1 deletion
2
christmas-task-part2/src/app/builders/controls/treePageControls/htmlForMediaForm.ts
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
24 changes: 13 additions & 11 deletions
24
christmas-task-part2/src/app/builders/controls/treePageControls/media-form.ts
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 |
---|---|---|
@@ -1,32 +1,34 @@ | ||
import { IState, IMediaForm } from '../../../types'; | ||
import setLocalStorage from '../../../utils/set-local-storage'; | ||
import { IState } from '../../../types'; | ||
// import setLocalStorage from '../../../utils/set-local-storage'; | ||
import buildHtmlForMediaForm from './htmlForMediaForm'; | ||
import renderMediaForm from '../../../renders/renderMediaForm'; | ||
// import renderMediaForm from '../../../renders/renderMediaForm'; | ||
import runMedia from '../../../utils/media/run-media'; | ||
|
||
const buildMediaForm = (state: IState): Node => { | ||
const formElement = document.createElement('form'); | ||
formElement.innerHTML = buildHtmlForMediaForm(state); | ||
formElement.classList.add('media-settings__form', 'form'); | ||
|
||
formElement.addEventListener('change', (e: Event): void => { | ||
const { audio, snow, garland } = state.mediaForm; | ||
|
||
const activeElement = e.target as HTMLInputElement; | ||
const { name } = activeElement; | ||
|
||
if (activeElement.checked) { | ||
state.mediaForm[name] = true; | ||
} else { | ||
state.mediaForm[name] = false; | ||
} | ||
|
||
|
||
renderMediaForm(state); | ||
//TODO | ||
// runMedia(state); | ||
// setLocalStorage(state); | ||
runMedia(state, [audio, snow, garland]); | ||
//TODO | ||
// setLocalStorage(state); | ||
|
||
// renderMediaForm(state); ??? | ||
}); | ||
|
||
|
||
return formElement; | ||
}; | ||
|
||
export default buildMediaForm; | ||
export default buildMediaForm; |
28 changes: 13 additions & 15 deletions
28
christmas-task-part2/src/app/builders/controls/treePageControls/tree-form.ts
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 |
---|---|---|
@@ -1,30 +1,28 @@ | ||
import { IState, ITreeForm } from '../../../types'; | ||
import setLocalStorage from '../../../utils/set-local-storage'; | ||
import { IState } from '../../../types'; | ||
// import setLocalStorage from '../../../utils/set-local-storage'; | ||
import buildHtmlForTreePageForm from './htmlForTreeForm'; | ||
import renderTreeForm from '../../../renders/renderTreeForm'; | ||
// import renderTreeForm from '../../../renders/renderTreeForm'; | ||
import changeDecorations from '../../../utils/decoration/change-decorations'; | ||
|
||
const buildTreeForm = (state: IState): Node => { | ||
const buildTreeForm = (state: IState): Node => { | ||
const formElement = document.createElement('form'); | ||
formElement.innerHTML = buildHtmlForTreePageForm(state); | ||
formElement.classList.add('tree-settings__form', 'form'); | ||
|
||
formElement.addEventListener('change', (e: Event): void => { | ||
const activeElement = e.target as HTMLInputElement; | ||
const { name } = activeElement; | ||
const { name } = activeElement; | ||
|
||
const currentValue = name === 'garland' | ||
? activeElement.value | ||
: Number(activeElement.value); | ||
|
||
state.treeForm[name] = currentValue; | ||
const currentValue = name === 'garland' ? activeElement.value : Number(activeElement.value); | ||
|
||
// renderTreeForm(state); фокус не срабатывает с клавиатурф потому что ререндер? | ||
state.treeForm[name] = currentValue; | ||
|
||
//TODO | ||
// setLocalStorage(state); | ||
}); | ||
changeDecorations(state); | ||
//TODO | ||
// setLocalStorage(state); | ||
}); | ||
|
||
return formElement; | ||
}; | ||
|
||
export default buildTreeForm; | ||
export default buildTreeForm; |
22 changes: 22 additions & 0 deletions
22
christmas-task-part2/src/app/builders/decoration-section.ts
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,22 @@ | ||
import { IState } from '../types'; | ||
|
||
const buildDecorationSection = (state: IState): Node => { | ||
const { tree, bg } = state.treeForm; | ||
const decorationSection = <HTMLElement>document.createElement('section'); | ||
decorationSection.classList.add('decoration', `bg-tree-${bg}`); | ||
|
||
decorationSection.innerHTML = ` | ||
<h2 class="decoration__title sr-only">Украшаемая ёлка</h2> | ||
<div class="decoration__snowflakes"></div> | ||
<div class="decoration__garland"></div> | ||
<map name="tree-map"> | ||
<area coords="365,699,189,706,113,683,31,608,2,555,2,539,18,437,73,351,106,224, | ||
161,134,243,-1,306,75,353,144,399,221,424,359,452,459,496,550,444,664" shape="poly"> | ||
</map> | ||
<img class="decoration__tree" src="./trees/${tree}.png" usemap="#tree-map" alt="украшаемая ёлка"> | ||
`; | ||
|
||
return decorationSection; | ||
}; | ||
|
||
export default buildDecorationSection; |
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
118 changes: 118 additions & 0 deletions
118
christmas-task-part2/src/app/builders/htmlForGarland.ts
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,118 @@ | ||
const buildHtmlForGarland = (garlandColor: string): string => | ||
`<ul class="lightrope lightrope--1"> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
</ul> | ||
<ul class="lightrope lightrope--2"> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
</ul> | ||
<ul class="lightrope lightrope--3"> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
</ul> | ||
<ul class="lightrope lightrope--4"> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
</ul> | ||
<ul class="lightrope lightrope--5"> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
</ul> | ||
<ul class="lightrope lightrope--6"> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
</ul> | ||
<ul class="lightrope lightrope--7"> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
<li class="${garlandColor}"></li> | ||
</ul> | ||
`; | ||
|
||
export default buildHtmlForGarland; |
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
Oops, something went wrong.