Skip to content
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

🧹 Add HedySelect custom element #5540

Merged
merged 49 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
212a35b
adding dropdown class
jpelay May 15, 2024
3b74de4
replace dropdowns in customize adventure with hedy dropdowns
jpelay May 16, 2024
4884c6f
refactor some functions
jpelay May 16, 2024
bfc5e4b
fix some errors
jpelay May 16, 2024
72afa72
adding templates to their own file
jpelay May 16, 2024
ec082f4
generic arrow movement
jpelay May 16, 2024
5486f35
move select to their own file
jpelay May 16, 2024
dcd957b
for some reason it doesnt work in the custom elements file
jpelay May 16, 2024
73bf4db
test select in public adventures
jpelay May 16, 2024
1950c53
adding default label
jpelay May 20, 2024
b92137d
Merge branch 'main' into generic-dropdown
jpelay May 20, 2024
077f51c
🤖 Automatically update generated files
jpelay May 20, 2024
84e53c5
change selects of public adventures
jpelay May 20, 2024
8079e66
Merge branch 'generic-dropdown' of https://github.com/hedyorg/hedy in…
jpelay May 20, 2024
04aaeff
🤖 Automatically update generated files
jpelay May 20, 2024
464d82e
export from custom elements file
jpelay May 21, 2024
ac437de
🤖 Automatically update generated files
jpelay May 21, 2024
c8f6f01
change name of element and remove inner select
jpelay May 21, 2024
12d1f8d
Merge branch 'generic-dropdown' of https://github.com/hedyorg/hedy in…
jpelay May 21, 2024
a8faabb
🤖 Automatically update generated files
jpelay May 21, 2024
1b2df46
fix tests
jpelay Jun 13, 2024
ef93027
🤖 Automatically update generated files
jpelay Jun 13, 2024
b6c48e7
Merge branch main into class overview redesign
jpelay Jun 13, 2024
bbfb166
Merge branch 'generic-dropdown' of https://github.com/hedyorg/hedy in…
jpelay Jun 13, 2024
19762ad
🤖 Automatically update generated files
jpelay Jun 13, 2024
4c69249
fix public adventures
jpelay Jun 19, 2024
c253a3b
Merge branch 'main' into generic-dropdown
jpelay Jun 19, 2024
503ef8b
fix tests
jpelay Jun 19, 2024
31a76a3
close dropdowns when clicking outside
jpelay Jul 17, 2024
95485f0
replace explore page filters
jpelay Jul 17, 2024
4e1071b
🤖 Automatically update generated files
jpelay Jul 17, 2024
1822e37
add translation for level error
jpelay Jul 17, 2024
2ad551b
Merge branch 'generic-dropdown' of https://github.com/hedyorg/hedy in…
jpelay Jul 17, 2024
f6822db
Merge branch 'main' into generic-dropdown
jpelay Jul 18, 2024
656bae3
fix merge
jpelay Jul 18, 2024
2335deb
🤖 Automatically update generated files
jpelay Jul 18, 2024
a772d24
style adventure page a bit better
jpelay Jul 18, 2024
9d9820c
Merge branch 'main' into generic-dropdown
jpelay Jul 18, 2024
a4cdaff
🤖 Automatically update generated files
jpelay Jul 18, 2024
570341f
fix cypress tests
jpelay Jul 19, 2024
4895c91
fix translations
jpelay Jul 19, 2024
c012d18
🤖 Automatically update generated files
jpelay Jul 19, 2024
8237308
Merge branch 'main' into generic-dropdown
jpelay Jul 30, 2024
8bf516c
🤖 Automatically update generated files
jpelay Jul 30, 2024
b7926f8
fixed translations files
jpelay Jul 30, 2024
318b8bc
🤖 Automatically update generated files
jpelay Jul 30, 2024
cfd858a
Update messages.po
jpelay Jul 30, 2024
e0fac2e
🤖 Automatically update generated files
jpelay Jul 30, 2024
404683b
Merge branch 'main' into generic-dropdown
mergify[bot] Jul 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding default label
  • Loading branch information
jpelay committed May 20, 2024
commit 1950c53d218edf749f75085995477425d8167dbb
7 changes: 7 additions & 0 deletions static/js/appbundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -104553,6 +104553,7 @@ def note_with_error(value, err):
const clone3 = template.content.cloneNode(true);
this.appendChild(clone3);
const select = this.querySelector("select");
const label = this.dataset["label"] || "";
if (select === null) {
throw new Error("Expected an inner select to go with the hedy-select component!");
}
Expand Down Expand Up @@ -104583,6 +104584,12 @@ def note_with_error(value, err):
}
}
}
const span = this.getElementsByTagName("span");
if (span.length !== 1) {
throw new Error("HedySelect should only have one span element!");
}
span[0].dataset["value"] = label;
span[0].innerHTML = label;
updateLabelText(this.querySelector(".dropdown"));
}
onOptionClick(_event) {
Expand Down
4 changes: 2 additions & 2 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions static/js/custom-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class HedySelect extends HTMLElement {
const clone = template.content.cloneNode(true) as HTMLElement;
this.appendChild(clone);
const select = this.querySelector('select');

const label = this.dataset['label'] || '';
if (select === null) {
throw new Error('Expected an inner select to go with the hedy-select component!')
}
Expand All @@ -29,7 +29,6 @@ export class HedySelect extends HTMLElement {
dropdownMenu.appendChild(newDiv)
newDiv.addEventListener('click', this.onOptionClick)
}

for (const option of options) {
const newDiv = document.createElement('div');
newDiv.classList.add('option');
Expand All @@ -44,6 +43,12 @@ export class HedySelect extends HTMLElement {
}
}
}
const span = this.getElementsByTagName('span')
if (span.length !== 1) {
throw new Error('HedySelect should only have one span element!');
}
span[0].dataset['value'] = label;
span[0].innerHTML = label;
updateLabelText(this.querySelector('.dropdown')!)
}

Expand Down
2 changes: 1 addition & 1 deletion templates/custom-elements-templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<button type="button" class="toggle-button font-semibold rounded inline-flex justify-between
appearance-none w-full border border-gray-200 text-gray-700 p-2 rounded"
onclick="hedyApp.toggleDropdown(event)">
<span class="label" data-value="{{_('used_in')}}">{{_('used_in')}}</span>
<span class="label"></span>
<svg class="fill-current h-6 w-6" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20">
<path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
Expand Down
6 changes: 3 additions & 3 deletions templates/customize-adventure.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h3 class="text-center mt-0 mb-4">{{_('general_settings')}}</h3>
<div class="flex flex-row items-center mb-4">
<label for="custom_adventure_classes" class="inline-block w-40 text-xl">{{_('used_in')}}</label>
<div class="flex-1">
<hedy-select id="classes_dropdown">
<hedy-select id="classes_dropdown" data-label="{{_('used_in')}}">
<select multiple>
{% for class in all_classes %}
<option {% if class.id in adventure.classes %}selected{% endif %} value="{{class.id}}">{{ class.name }}</option>
Expand All @@ -37,7 +37,7 @@ <h3 class="text-center mt-0 mb-4">{{_('general_settings')}}</h3>
<div class="flex flex-row items-center mb-4">
<label for="custom_adventure_levels" class="inline-block w-40 text-xl">{{_('available_in')}}</label>
<div class="flex-1">
<hedy-select id="levels_dropdown">
<hedy-select id="levels_dropdown" data-label="{{_('select_levels')}}">
<select multiple>
{% for i in range(1, (max_level + 1)) %}
{% set adv_levels = adventure.levels if adventure.get("levels") else [adventure.level|string] %}
Expand All @@ -50,7 +50,7 @@ <h3 class="text-center mt-0 mb-4">{{_('general_settings')}}</h3>
<div class="flex flex-row items-center mb-4">
<label class="inline-block w-40 text-xl" for="language">{{_('language')}}</label>
<div class="flex-1">
<hedy-select id="languages_dropdown">
<hedy-select id="languages_dropdown" data-label="{{_('select_lang')}}">
<select>
<option value="{{ adventure['language'] or current_language().lang }}" selected>{{ lang_to_sym(adventure['language'] or current_language().lang) }}</option>
{% for language in other_languages(adventure["language"]) %}
Expand Down
Loading