Skip to content

Commit d24a654

Browse files
committed
feat: add homepage to not be seen when a generator is clicked
closes #155
2 parents 6ca1e15 + 0efc88b commit d24a654

File tree

4 files changed

+52
-27
lines changed

4 files changed

+52
-27
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ <h2>
373373

374374
<label id="degree">
375375
<span class="label-title">
376-
<span>Speed</span>
377-
<span id="degree-display">deg</span>
376+
<span class="title-display">Angle</span>
377+
<span class="unit-display animation">deg</span>
378378
</span>
379379
<input
380380
type="range"

src/main.ts

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ const gradientBackgroundDegree = getRange('gradient-background');
114114
// get all range inputs
115115
const gradientRangeInputs = document.querySelectorAll('.degree-range');
116116

117+
// get title display element for animation
118+
const titleDisplayElement = <HTMLElement>(
119+
document.querySelector('.title-display')
120+
);
121+
117122
menuIcon?.addEventListener('click', () => {
118123
if (navBar?.classList.contains('closed-nav')) {
119124
navBar?.animate(navBarSlideIn, navBarAnimationOptions);
@@ -142,7 +147,9 @@ if (getComputedStyle(menu).display == 'block') {
142147

143148
for (let i = 0; i < generators.length; i++) {
144149
generators[i].addEventListener('click', () => {
145-
navBar?.animate(navBarSlideOut, navBarAnimationOptions);
150+
if (!navBar?.classList.contains('closed-nav')) {
151+
navBar?.animate(navBarSlideOut, navBarAnimationOptions);
152+
}
146153
navBar?.classList.add('closed-nav');
147154
menuIcon?.setAttribute('icon', 'dashicons:menu-alt');
148155
});
@@ -151,6 +158,11 @@ for (let i = 0; i < generators.length; i++) {
151158
FilePond.create(getImageEntryElement, {
152159
imagePreviewMaxHeight: 200,
153160

161+
labelIdle:
162+
window.innerWidth < 768
163+
? '<span class="filepond--label-action">Browse</span>'
164+
: 'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>',
165+
154166
onpreparefile: (fileItem, output): void => {
155167
// create a new image object
156168
const img = new Image();
@@ -269,17 +281,6 @@ function showResult(attribute: string | null) {
269281
generatorsFunction(attribute);
270282
}
271283

272-
// display current gradient value for all range inputs
273-
const displayGradientValue = (gradientElement: HTMLInputElement) => {
274-
gradientElement.addEventListener('input', (e) => {
275-
const target = e.target as HTMLInputElement;
276-
const degreeDisplayElement = <HTMLElement>(
277-
target.parentElement?.querySelector('#degree-display')
278-
);
279-
degreeDisplayElement.innerText = `${target.value}deg`;
280-
});
281-
};
282-
283284
getHeaderText?.addEventListener('click', () => {
284285
if (getHomePage === null || getGeneratorSection === null) return;
285286
getHomePage.style.display = 'flex';
@@ -323,6 +324,22 @@ closeBar?.addEventListener('click', () => {
323324
}, 600);
324325
});
325326

327+
// display current gradient value for all range inputs
328+
const displayGradientValue = (gradientElement: HTMLInputElement) => {
329+
gradientElement.addEventListener('input', (e) => {
330+
const target = e.target as HTMLInputElement;
331+
const unitDisplayElement = <HTMLElement>(
332+
target.parentElement?.querySelector('.unit-display')
333+
);
334+
335+
// change the unit for opacity
336+
const unit = titleDisplayElement.innerText.toLowerCase().includes('opacity')
337+
? ''
338+
: 'deg';
339+
unitDisplayElement.innerText = `${target.value}${unit}`;
340+
});
341+
};
342+
326343
gradientRangeInputs.forEach((gradientRangeInput: HTMLInputElement) => {
327344
displayGradientValue(gradientRangeInput);
328345
});

src/pages/animation.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,25 @@ type Values = {
1212
};
1313

1414
const attribute = 'animation';
15-
let getCodeButtonElement = utils.getCopyCodeButton(attribute);
15+
let getCodeButtonElement = utils.getCopyCodeButton(attribute);
16+
17+
const OutputElement = utils.getOutput(attribute);
18+
const DegreeElement = utils.getRange(attribute);
19+
const radio_button_set = utils.getRadioButtonSet(attribute);
20+
21+
initialConfiguration(radio_button_set, DegreeElement, OutputElement);
1622

1723
export function animationGenerator() {
18-
const DegreeElement = utils.getRange(attribute);
1924
const duration = utils.getInputSpinner(attribute);
20-
const radio_button_set = utils.getRadioButtonSet(attribute);
21-
22-
const OutputElement = utils.getOutput(attribute);
2325

2426
const Stylesheet = utils.getStyleSheet();
2527
// getCodeButtonElement = utils.getCopyCodeButton(attribute);
2628
const resultPage = utils.getResultPage();
27-
28-
resultPage.style.display = 'flex';
2929

30-
30+
resultPage.style.display = 'flex';
3131

3232
initial_length = Stylesheet.cssRules.length - 1;
3333

34-
initialConfiguration(radio_button_set, DegreeElement, OutputElement);
35-
3634
if (OutputElement === null) return;
3735

3836
let i = 0;
@@ -58,8 +56,6 @@ getCodeButtonElement.addEventListener('click', () => {
5856
);
5957
});
6058

61-
62-
6359
/**
6460
* sets the animation to the output element
6561
*
@@ -166,6 +162,14 @@ function initialConfiguration(
166162

167163
OutputElement.innerText = 'Lorem Ipsum';
168164

165+
// get the unit display element for animator
166+
const unitDisplayElement = <HTMLElement>(
167+
document.querySelector('.unit-display.animation')
168+
);
169+
const titleDisplayElement = <HTMLElement>(
170+
document.querySelector('.title-display')
171+
);
172+
169173
elements.forEach((el) =>
170174
el.addEventListener('click', () => {
171175
const type = el.value;
@@ -174,11 +178,15 @@ function initialConfiguration(
174178
DegreeElement.max = '90';
175179
DegreeElement.step = '1';
176180
DegreeElement.value = '50';
181+
unitDisplayElement.innerText = `${DegreeElement.value}deg`;
182+
titleDisplayElement.innerText = 'Angle';
177183
} else {
178184
DegreeElement.min = '0';
179185
DegreeElement.max = '1';
180186
DegreeElement.step = '.1';
181187
DegreeElement.value = '.5';
188+
unitDisplayElement.innerText = `${DegreeElement.value}`;
189+
titleDisplayElement.innerText = 'Opacity';
182190
}
183191
})
184192
);

src/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ input[type='number']::-webkit-outer-spin-button {
327327
align-items: center;
328328
}
329329

330-
#degree-display {
330+
.unit-display {
331331
opacity: 0.7;
332332
}
333333

0 commit comments

Comments
 (0)