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 all commits
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
2 changes: 2 additions & 0 deletions build-tools/heroku/generate-client-messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
'adventures_restored',
'multiple_keywords_warning',
'selected',
'select_all',
'one_level_error',
'adventures_tried',
'graph_title',
'errors',
Expand Down
4 changes: 3 additions & 1 deletion content/client-messages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ gettext('disabled')
gettext('adventures_restored')
gettext('multiple_keywords_warning')
gettext('selected')
gettext('select_all')
gettext('one_level_error')
gettext('adventures_tried')
gettext('graph_title')
gettext('errors')
gettext('adventures_completed')
gettext('number_of_errors')
gettext('successful_runs')
gettext('successful_runs')
9 changes: 6 additions & 3 deletions messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ msgstr ""
msgid "ask_needs_var"
msgstr ""

msgid "available_in"
msgstr ""

msgid "become_a_sponsor"
msgstr ""

Expand Down Expand Up @@ -632,9 +635,6 @@ msgstr ""
msgid "expiration_date"
msgstr ""

msgid "explore_explanation"
msgstr ""

msgid "explore_programs"
msgstr ""

Expand Down Expand Up @@ -1157,6 +1157,9 @@ msgstr ""
msgid "ok"
msgstr ""

msgid "one_level_error"
msgstr ""

msgid "only_you_can_see"
msgstr ""

Expand Down
16 changes: 9 additions & 7 deletions static/js/adventure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import TRADUCTION_IMPORT from '../../highlighting/highlighting-trad.json';
import { convert } from "./utils";
import { ClientMessages } from "./client-messages";
import { autoSave } from "./autosave";
import { HedySelect } from "./custom-elements";

declare let window: CustomWindow;

Expand All @@ -23,7 +24,7 @@ export async function initializeCustomAdventurePage(_options: InitializeCustomiz
const editorContainer = document.querySelector('#adventure-editor') as HTMLElement;
const editorSolutionExampleContainer = document.querySelector('#adventure-solution-editor') as HTMLElement;
// Initialize the editor with the default language
let lang = document.querySelector('#languages_dropdown> .option.selected')!.getAttribute('data-value') as string
let lang = (document.querySelector('#languages_dropdown') as HedySelect).selected[0]
const TRADUCTIONS = convert(TRADUCTION_IMPORT) as Map<string, Map<string,string>>;
if (!TRADUCTIONS.has(lang)) { lang = 'en'; }
let TRADUCTION = TRADUCTIONS.get(lang) as Map<string,string>;
Expand All @@ -38,22 +39,23 @@ export async function initializeCustomAdventurePage(_options: InitializeCustomiz
}

$('#language').on('change', () => {
let lang = document.querySelector('#languages_dropdown> .option.selected')!.getAttribute('data-value') as string
let lang = (document.querySelector('#languages_dropdown') as HedySelect).selected[0]
if (!TRADUCTIONS.has(lang)) { lang = 'en'; }
TRADUCTION = TRADUCTIONS.get(lang) as Map<string,string>;
})

// Autosave customize adventure page
autoSave("customize_adventure")

showWarningIfMultipleLevels()
document.querySelectorAll('#levels_dropdown > .option').forEach((el) => {
showWarningIfMultipleLevels()
document.querySelectorAll('#levels_dropdown div div .option').forEach((el) => {
el.addEventListener('click', () => {
setTimeout(showWarningIfMultipleLevels, 100)
setTimeout(showWarningIfMultipleLevels, 100)
})
})
}
function showWarningIfMultipleLevels() {
const numberOfLevels = document.querySelectorAll('#levels_dropdown > .option.selected').length;
const numberOfLevels = (document.querySelector('#levels_dropdown') as HedySelect).selected.length;
const numberOfSnippets = document.querySelectorAll('pre[data-language="Hedy"]').length
if(numberOfLevels > 1 && numberOfSnippets > 0) {
$('#warningbox').show()
Expand Down Expand Up @@ -208,7 +210,7 @@ export function addCurlyBracesToCode(code: string, level: number, language: stri
}

export function addCurlyBracesToKeyword(name: string) {
let lang = document.querySelector('#languages_dropdown> .option.selected')!.getAttribute('data-value') as string
let lang = (document.querySelector('#languages_dropdown') as HedySelect).selected[0]
const TRADUCTIONS = convert(TRADUCTION_IMPORT) as Map<string, Map<string,string>>;
if (!TRADUCTIONS.has(lang)) { lang = 'en'; }
let TRADUCTION = TRADUCTIONS.get(lang) as Map<string,string>;
Expand Down
4 changes: 2 additions & 2 deletions static/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { stopDebug } from "./debugging";
import { HedyCodeMirrorEditorCreator } from './cm-editor';
import { initializeTranslation } from './lezer-parsers/tokens';
import { initializeActivity } from './user-activity';

export let theGlobalDebugger: any;
export let theGlobalEditor: HedyEditor;
export let theModalEditor: HedyEditor;
Expand Down Expand Up @@ -118,6 +117,7 @@ const slides_template = `
</html>
`;


export interface InitializeAppOptions {
readonly level: number;
readonly keywordLanguage: string;
Expand Down Expand Up @@ -2023,4 +2023,4 @@ export function goToLevel(level: any) {
}
window.location.pathname = newPath
window.location.hash = hash
}
}
Loading
Loading