diff --git a/frontend/src/ts/constants/british-english.ts b/frontend/src/ts/constants/british-english.ts new file mode 100644 index 000000000000..7aec00333a47 --- /dev/null +++ b/frontend/src/ts/constants/british-english.ts @@ -0,0 +1,681 @@ +type ExceptionRule = { britishWord: string; exceptPreviousWords: string[] }; +type BritishEnglishReplacements = Record< + string /*EnglishWord*/, + string /*BritishWord*/ | ExceptionRule +>; +const britishEnglishReplacements: BritishEnglishReplacements = { + laborers: "labourers", + industrialized: "industrialised", + acclimatizing: "acclimatising", + acclimatized: "acclimatised", + behoove: "behove", + reorganization: "reorganisation", + galvanize: "galvanise", + demagogism: "demagoguism", + canceled: "cancelled", + baptize: "baptise", + revitalize: "revitalise", + skeptical: "sceptical", + piscine: "piscinae", + ionization: "ionisation", + chili: "chilli", + dexterous: "dextrous", + likable: "likeable", + neutralize: "neutralise", + meter: "metre", + meters: "metres", + centimeter: "centimetre", + hurrah: "hooray", + multicolor: "multicolour", + actualization: "actualisation", + fertilizing: "fertilising", + enamor: "enamour", + skepticism: "scepticism", + authorize: "authorise", + minimize: "minimise", + bandoleer: "bandolier", + rigor: "rigour", + fledgling: "fledgeling", + mesquite: "mesquit", + fogy: "fogey", + characterize: "characterise", + wagonette: "waggonette", + plagiarize: "plagiarise", + kilometers: "kilometres", + molt: "moult", + leveler: "leveller", + checkered: "chequered", + vendor: "vender", + candor: "candour", + moralize: "moralise", + denationalization: "denationalisation", + anemia: "anaemia", + caiman: "cayman", + chitterlings: "chitlins", + acclimated: "acclimatised", + acclimate: "acclimatise", + skillful: "skilful", + enamored: "enamoured", + watercolor: "watercolour", + extemporization: "extemporisation", + lackluster: "lacklustre", + equalizer: "equaliser", + cipher: "cypher", + polarization: "polarisation", + polymerization: "polymerisation", + ionize: "ionise", + anesthetic: "anaesthetic", + aerie: "eyrie", + lachrymal: "lacrimal", + decimeter: "decimetre", + rajah: "raja", + modernize: "modernise", + gasoline: "petrol", + alphabetized: "alphabetised", + saber: "sabre", + burglarize: "burglarise", + terrorize: "terrorise", + enthrall: "enthral", + mustachioed: "moustachioed", + anesthesia: "anaesthesia", + sepulcher: "sepulchre", + caftan: "kaftan", + organize: "organise", + manikin: "mannikin", + dexterously: "dextrously", + artifact: "artefact", + kilometer: "kilometre", + mommy: "mummy", + brant: "brent", + hyena: "hyaena", + fuze: "fuse", + victimize: "victimise", + jihad: "jehad", + airplane: "aeroplane", + laborer: "labourer", + vaporware: "vapourware", + worshiped: "worshipped", + taboret: "tabouret", + rationalize: "rationalise", + whimsy: "whimsey", + scandalize: "scandalise", + categorization: "categorisation", + centered: "centred", + kerosene: "kerosine", + specialize: "specialise", + specialized: "specialised", + cicatrix: "cicatrice", + jailer: "jailor", + unfavorable: "unfavourable", + guerrilla: "guerilla", + emphasize: "emphasise", + wacky: "whacky", + ionizing: "ionising", + czarina: "tzarina", + ratline: "ratlin", + abolitionize: "abolitionise", + subsidize: "subsidise", + plowing: "ploughing", + untrammeled: "untrammelled", + worshiping: "worshipping", + memorization: "memorisation", + anglicize: "anglicise", + finalize: "finalise", + gases: "gasses", + fertilization: "fertilisation", + libeling: "libelling", + kinesthetic: "kinaesthetic", + immunization: "immunisation", + coloration: "colouration", + overdraft: "overdraught", + lambaste: "lambast", + unpasteurized: "unpasteurised", + ascendance: "ascendence", + jeweler: "jeweller", + fervor: "fervour", + jeopardize: "jeopardise", + abridgment: "abridgement", + monopolize: "monopolise", + colorless: "colourless", + colorlessness: "colourlessness", + tumors: "tumours", + jinni: "jinn", + aluminum: "aluminium", + salable: "saleable", + bronco: "broncho", + lupine: "lupin", + linchpin: "lynchpin", + mesmerize: "mesmerise", + internationalization: "internationalisation", + anapestic: "anapaestic", + supersede: "supercede", + europeanize: "europeanise", + optimized: "optimised", + botanize: "botanise", + organizational: "organisational", + heme: "haem", + estivation: "aestivation", + edema: "oedema", + penalize: "penalise", + peddler: "pedlar", + biased: "biassed", + aggrandize: "aggrandise", + rationalizing: "rationalising", + deputize: "deputise", + centers: "centres", + unicolor: "unicolour", + hypnotized: "hypnotised", + anglicized: "anglicised", + initialization: "initialisation", + topee: "topi", + nightie: "nighty", + tricolor: "tricolour", + reorganize: "reorganise", + barbecue: "barbeque", + fertilized: "fertilised", + synthesize: "synthesise", + economize: "economise", + colter: "coulter", + paleontologist: "palaeontologist", + acclimatize: "acclimatise", + idealize: "idealise", + fossilization: "fossilisation", + lionize: "lionise", + acclimating: "acclimatising", + luster: "lustre", + demeanor: "demeanour", + unauthorized: "unauthorised", + smolder: "smoulder", + abettor: "abetter", + jewelry: "jewellery", + demoralization: "demoralisation", + fullness: "fulness", + neighbored: "neighboured", + neighbor: "neighbour", + neighbors: "neighbours", + neighboring: "neighbouring", + neighborly: "neighbourly", + neighborhood: "neighbourhood", + neighborhoods: "neighbourhoods", + magnetizer: "magnetiser", + appetizer: "appetiser", + hebraizing: "hebraising", + carbonization: "carbonisation", + favorably: "favourably", + favorite: "favourite", + behavioral: "behavioural", + cognizant: "cognisant", + skeptic: "sceptic", + fiber: "fibre", + fibers: "fibres", + labeled: "labelled", + analyze: "analyse", + disorganization: "disorganisation", + concenter: "concentre", + categorize: "categorise", + novelization: "novelisation", + proselytize: "proselytise", + draftsman: "draughtsman", + paralyze: "paralyse", + ostracize: "ostracise", + italicize: "italicise", + micrometer: "micrometre", + cognizance: "cognisance", + saltpeter: "saltpetre", + conceptualization: "conceptualisation", + containerization: "containerisation", + anapest: "anapaest", + leukemia: "leukaemia", + omelet: "omelette", + industrialize: "industrialise", + characterization: "characterisation", + amortize: "amortise", + mazurka: "mazourka", + macadamize: "macadamise", + stymie: "stymy", + analog: "analogue", + prizer: "priser", + cauterize: "cauterise", + dysmenorrhea: "dysmenorrhoea", + hippie: "hippy", + mechanization: "mechanisation", + commercialize: "commercialise", + unsavory: "unsavoury", + somber: "sombre", + esophageal: "oesophageal", + iodized: "iodised", + tyrannize: "tyrannise", + liberalize: "liberalise", + computerization: "computerisation", + synthesizer: "synthesiser", + fertilizes: "fertilises", + airdrome: "aerodrome", + uncivilized: "uncivilised", + mold: "mould", + nitrogenized: "nitrogenised", + legalize: "legalise", + tantalize: "tantalise", + eulogize: "eulogise", + depolarization: "depolarisation", + fecal: "faecal", + bastardize: "bastardise", + summarize: "summarise", + cony: "coney", + authorization: "authorisation", + colorful: "colourful", + temporized: "temporised", + adviser: "advisor", + tendinitis: "tendonitis", + crystallization: "crystallisation", + humor: "humour", + humorous: "humourous", + chanty: "shanty", + dyspnea: "dyspnoea", + aging: "ageing", + mousy: "mousey", + succor: "succour", + distill: "distil", + decentralization: "decentralisation", + cauterization: "cauterisation", + specter: "spectre", + snowplow: "snowplough", + pediatrics: "paediatrics", + discoloration: "discolouration", + tumor: "tumour", + empathize: "empathise", + pawpaw: "papaya", + aggrandizement: "aggrandisement", + fontanel: "fontanelle", + brunet: "brunette", + rumor: "rumour", + epaulet: "epaulette", + glycerin: "glycerine", + fraternize: "fraternise", + latinize: "latinise", + sniveling: "snivelling", + pasteurize: "pasteurise", + modernization: "modernisation", + patronize: "patronise", + totaled: "totalled", + normalization: "normalisation", + niter: "nitre", + shoveler: "shoveller", + flier: "flyer", + equalization: "equalisation", + meagerly: "meagrely", + favoritism: "favouritism", + libelous: "libellous", + popularized: "popularised", + armory: "armoury", + humanization: "humanisation", + minuscule: "miniscule", + collectible: "collectable", + tepee: "teepee", + stabilization: "stabilisation", + moldy: "mouldy", + colonize: "colonise", + idealized: "idealised", + meager: "meagre", + armorer: "armourer", + vitalize: "vitalise", + fossilized: "fossilised", + antagonize: "antagonise", + criticize: "criticise", + liter: "litre", + stigmatize: "stigmatise", + theorize: "theorise", + combated: "combatted", + desalination: "desalinisation", + evangelize: "evangelise", + idolization: "idolisation", + smoldering: "smouldering", + commercialization: "commercialisation", + laureled: "laurelled", + hematology: "haematology", + fulfill: "fulfil", + disorganized: "disorganised", + accouterments: "accoutrements", + busses: "buses", + utilize: "utilise", + enroll: "enrol", + goiter: "goitre", + stylized: "stylised", + diarrhea: "diarrhoea", + hypothesize: "hypothesise", + esthetic: "aesthetic", + dishonor: "dishonour", + victualer: "victualler", + paleolithic: "palaeolithic", + sanatorium: "sanitarium", + feminization: "feminisation", + flotation: "floatation", + teetotaler: "teetotaller", + feudalization: "feudalisation", + visualize: "visualise", + fertilize: "fertilise", + czar: "tzar", + nationalization: "nationalisation", + septicemia: "septicaemia", + organizer: "organiser", + recrystallization: "recrystallisation", + dolor: "dolour", + agonizing: "agonising", + romanization: "romanisation", + synchronize: "synchronise", + amorist: "amourist", + agonized: "agonised", + belabor: "belabour", + caster: "castor", + softy: "softie", + apothegm: "apophthegm", + demobilization: "demobilisation", + agonizes: "agonises", + misdemeanor: "misdemeanour", + recognizable: "recognisable", + asshole: "arsehole", + brutalization: "brutalisation", + chamois: "shammy", + clamor: "clamour", + fertilizer: "fertiliser", + deodorization: "deodorisation", + privatization: "privatisation", + tidbit: "titbit", + molding: "moulding", + alleluia: "halleluiah", + canonization: "canonisation", + customize: "customise", + customization: "customisations", + customizer: "customiser", + customizers: "customisers", + customizes: "customises", + customizing: "customising", + popularize: "popularise", + specialty: "speciality", + meagerness: "meagreness", + esophagus: "oesophagus", + millimeter: "millimetre", + harmonization: "harmonisation", + atomizer: "atomiser", + dieresis: "diaeresis", + maneuver: "manoeuvre", + capitalize: "capitalise", + gynecologist: "gynaecologist", + acclimation: "acclimatisation", + generalize: "generalise", + temporize: "temporise", + premunire: "praemunire", + estival: "aestival", + selvage: "selvedge", + brier: "briar", + hyperesthesia: "hyperaesthesia", + maximize: "maximise", + draftsmen: "draughtsmen", + colonization: "colonisation", + capitalization: "capitalisation", + tenia: "taenia", + paleontology: "palaeontology", + libeler: "libeller", + arytenoid: "arytaenoid", + wainscoting: "wainscotting", + globalization: "globalisation", + legalization: "legalisation", + magnetization: "magnetisation", + stabilize: "stabilise", + mesmerized: "mesmerised", + savory: "savoury", + reconnoiter: "reconnoitre", + bastardized: "bastardised", + rancor: "rancour", + checker: "chequer", + industrialization: "industrialisation", + epitomize: "epitomise", + socialize: "socialise", + externalization: "externalisation", + chivy: "chivvy", + optimize: "optimise", + romanize: "romanise", + vulcanize: "vulcanise", + plow: "plough", + memorize: "memorise", + sterilization: "sterilisation", + routing: "routeing", + raveling: "ravelling", + savor: "savour", + harmonize: "harmonise", + cannibalize: "cannibalise", + vaporize: "vaporise", + utilization: "utilisation", + hybridization: "hybridisation", + mechanize: "mechanise", + arbor: "arbour", + arbors: "arbours", + licorice: "liquorice", + counselor: "counsellor", + orthopedic: "orthopaedic", + lusterless: "lustreless", + numskull: "numbskull", + paleozoic: "palaeozoic", + malodor: "malodour", + amenorrhea: "amenorrhoea", + criticized: "criticised", + gonorrhea: "gonorrhoea", + fossilize: "fossilise", + revolutionize: "revolutionise", + woolen: "woollen", + dishabille: "deshabille", + organdy: "organdie", + asses: "arses", + furor: "furore", + paycheck: "paycheque", + pulverize: "pulverise", + dramatization: "dramatisation", + yodeler: "yodeller", + apologize: "apologise", + apologized: "apologised", + blond: "blonde", + oxidize: "oxidise", + extemporize: "extemporise", + whiz: "whizz", + edile: "aedile", + appall: "appal", + legitimize: "legitimise", + urbanization: "urbanisation", + magnetize: "magnetise", + womanize: "womanise", + orthopedics: "orthopaedics", + cognize: "cognise", + christianization: "christianisation", + vocalize: "vocalise", + individualization: "individualisation", + hemoglobin: "haemoglobin", + racket: "racquet", + agonize: "agonise", + aggrandizes: "aggrandises", + accouter: "accoutre", + mollusk: "mollusc", + publicize: "publicise", + fraternization: "fraternisation", + odorless: "odourless", + odor: "odour", + odorous: "odourous", + rationalization: "rationalisation", + pretense: "pretence", + louver: "louvre", + kopeck: "kopek", + lissome: "lissom", + idealization: "idealisation", + nosy: "nosey", + stogie: "stogy", + althea: "althaea", + immobilization: "immobilisation", + majolica: "maiolica", + savior: "saviour", + civilize: "civilise", + granddad: "grandad", + centralization: "centralisation", + localization: "localisation", + evangelization: "evangelisation", + ruble: "rouble", + pajamas: "pyjamas", + sterilize: "sterilise", + math: "maths", + localize: "localise", + hospitalization: "hospitalisation", + scrutinize: "scrutinise", + acclimatization: "acclimatisation", + misbehavior: "misbehaviour", + behavior: "behaviour", + color: "colour", + tire: { britishWord: "tyre", exceptPreviousWords: ["will"] }, + gray: "grey", + grays: "greys", + theater: "theatre", + amphitheater: "amphitheatre", + center: "centre", + realize: "realise", + realizing: "realising", + realization: "realisation", + license: "licence", + mom: "mum", + "mom'l": "mum'll", + favor: "favour", + favors: "favours", + favorites: "favourites", + analyzed: "analysed", + characterized: "characterised", + colored: "coloured", + colors: "colours", + counseling: "counselling", + customized: "customised", + defense: "defence", + offense: "offence", + enrollment: "enrolment", + flavor: "flavour", + flavors: "flavours", + flavoring: "flavouring", + harbor: "harbour", + harbored: "harboured", + honor: "honour", + honors: "honours", + labor: "labour", + licensed: "licenced", + licenses: "licences", + licensing: "licencing", + modeling: "modelling", + optimization: "optimisation", + organization: "organisation", + organizations: "organisations", + organized: "organised", + organizing: "organising", + pediatric: "paediatric", + personalized: "personalised", + practice: "practise", + realized: "realised", + recognize: "recognise", + recognized: "recognised", + specialties: "specialities", + specializing: "specialising", + theaters: "theatres", + travelers: "travellers", + traveler: "traveller", + traveling: "travelling", + authorized: "authorised", + behaviors: "behaviours", + traveled: "travelled", + utilizing: "utilising", + utilized: "utilised", + honored: "honoured", + specializes: "specialises", + practicing: "practising", + signaling: "signalling", + analyzing: "analysing", + recognizes: "recognises", + organizers: "organisers", + visualization: "visualisation", + standardized: "standardised", + favorable: "favourable", + analyzer: "analyser", + recognizing: "recognising", + uncategorized: "uncategorised", + categorized: "categorised", + vapor: "vapour", + synchronization: "synchronisation", + synchronized: "synchronised", + rumors: "rumours", + coloring: "colouring", + honorable: "honourable", + generalized: "generalised", + generalization: "generalisation", + mobilize: "mobilise", + armor: "armour", + armored: "armoured", + labeling: "labelling", + endeavor: "endeavour", + civilized: "civilised", + civilization: "civilisation", + parlor: "parlour", + tranquilize: "tranquilise", + tranquillized: "tranquillised", + tranquillization: "tranquillisation", + catalog: "catalogue", + cataloger: "cataloguer", + cataloging: "cataloguing", + catalogs: "catalogues", + cataloged: "catalogued", + uncataloged: "uncatalogued", + catalogers: "cataloguers", + discolored: "discoloured", + discolor: "discolour", + encyclopedias: "encyclopaedias", + endeavored: "endeavoured", + endeavors: "endeavours", + endeavoring: "endeavouring", + judgments: "judgements", + judgment: "judgement", + paneling: "panelling", + defenses: "defences", + criticizing: "criticising", + mustache: "moustache", + emphasized: "emphasised", + emphasizes: "emphasises", + emphasizing: "emphasising", + fetus: "foetus", + programs: "programmes", + yogurt: "yoghurt", + valor: "valour", + moisturize: "moisturise", + moisturized: "moisturised", + moisturizes: "moisturises", + moisturizing: "moisturising", + favoring: "favouring", + marvelous: "marvellous", + hematuria: "haematuria", + hemoptysis: "haemoptysis", + hemorrhoid: "haemorrhoid", + hemorrhagic: "haemorrhagic", + hypercalcemia: "hypercalcaemia", + hyperglycemia: "hyperglycaemia", + hypoglycemia: "hypoglycaemia", + toxemia: "toxaemia", + hypoxemia: "hypoxaemia", + bacteremia: "bacteraemia", + hypernatremia: "hypernatraemia", + hyponatremia: "hyponatraemia", + leukocytosis: "leucocytosis", + leukocyte: "leucocyte", + leukopenia: "leucopenia", + apnea: "apnoea", + bradypnea: "bradypnoea", + tachypnea: "tachypnoea", + orthopnea: "orthopnoea", + ileocecal: "ileocaecal", + metastasize: "metastasise", + lymphedema: "lymphoedema", + neuron: "neurone", + hemianopsia: "hemianopia", + galactorrhea: "galactorrhoea", + nebulizer: "nebuliser", + paresthesia: "paraesthesia", +}; + +export default britishEnglishReplacements; diff --git a/frontend/src/ts/constants/keys.ts b/frontend/src/ts/constants/keys.ts new file mode 100644 index 000000000000..6875e53d770a --- /dev/null +++ b/frontend/src/ts/constants/keys.ts @@ -0,0 +1,228 @@ +export type Keycode = + | "Backquote" + | "Digit1" + | "Digit2" + | "Digit3" + | "Digit4" + | "Digit5" + | "Digit6" + | "Digit7" + | "Digit8" + | "Digit9" + | "Digit0" + | "Minus" + | "Equal" + | "KeyQ" + | "KeyW" + | "KeyE" + | "KeyR" + | "KeyT" + | "KeyY" + | "KeyU" + | "KeyI" + | "KeyO" + | "KeyP" + | "BracketLeft" + | "BracketRight" + | "Backslash" + | "KeyA" + | "KeyS" + | "KeyD" + | "KeyF" + | "KeyG" + | "KeyH" + | "KeyJ" + | "KeyK" + | "KeyL" + | "Semicolon" + | "Quote" + | "KeyZ" + | "KeyX" + | "KeyC" + | "KeyV" + | "KeyB" + | "KeyN" + | "KeyM" + | "Comma" + | "Period" + | "Slash" + | "Space" + | "ShiftLeft" + | "IntlBackslash" + | "ShiftRight" + | "ArrowUp" + | "ArrowLeft" + | "ArrowDown" + | "ArrowRight" + | "NumpadMultiply" + | "NumpadSubtract" + | "NumpadAdd" + | "NumpadDecimal" + | "NumpadEqual" + | "NumpadDivide" + | "Numpad0" + | "Numpad1" + | "Numpad2" + | "Numpad3" + | "Numpad4" + | "Numpad5" + | "Numpad6" + | "Numpad7" + | "Numpad8" + | "Numpad9" + | "NumpadEnter" + | "Enter" + | "Backspace"; + +export const qwertyKeycodeKeymap: Keycode[][] = [ + [ + "Backquote", + "Digit1", + "Digit2", + "Digit3", + "Digit4", + "Digit5", + "Digit6", + "Digit7", + "Digit8", + "Digit9", + "Digit0", + "Minus", + "Equal", + ], + [ + "KeyQ", + "KeyW", + "KeyE", + "KeyR", + "KeyT", + "KeyY", + "KeyU", + "KeyI", + "KeyO", + "KeyP", + "BracketLeft", + "BracketRight", + "Backslash", + ], + [ + "KeyA", + "KeyS", + "KeyD", + "KeyF", + "KeyG", + "KeyH", + "KeyJ", + "KeyK", + "KeyL", + "Semicolon", + "Quote", + ], + [ + "KeyZ", + "KeyX", + "KeyC", + "KeyV", + "KeyB", + "KeyN", + "KeyM", + "Comma", + "Period", + "Slash", + ], + ["Space"], +]; + +export const leftSideKeys: Set = new Set([ + "Backquote", + "Digit1", + "Digit2", + "Digit3", + "Digit4", + "Digit5", + "Digit6", + + "KeyQ", + "KeyW", + "KeyE", + "KeyR", + "KeyT", + "KeyY", + + "KeyA", + "KeyS", + "KeyD", + "KeyF", + "KeyG", + + "ShiftLeft", + "IntlBackslash", + "KeyZ", + "KeyX", + "KeyC", + "KeyV", + "KeyB", + + "Space", +]); + +export const rightSideKeys: Set = new Set([ + "Digit6", + "Digit7", + "Digit8", + "Digit9", + "Digit0", + "Minus", + "Equal", + "Backspace", + + "KeyY", + "KeyU", + "KeyI", + "KeyO", + "KeyP", + "BracketLeft", + "BracketRight", + "Backslash", + + "KeyH", + "KeyJ", + "KeyK", + "KeyL", + "Semicolon", + "Quote", + "Enter", + + "KeyB", + "KeyN", + "KeyM", + "Comma", + "Period", + "Slash", + "ShiftRight", + + "ArrowUp", + "ArrowLeft", + "ArrowDown", + "ArrowRight", + + "NumpadMultiply", + "NumpadSubtract", + "NumpadAdd", + "NumpadDecimal", + "NumpadEqual", + "NumpadDivide", + "Numpad0", + "Numpad1", + "Numpad2", + "Numpad3", + "Numpad4", + "Numpad5", + "Numpad6", + "Numpad7", + "Numpad8", + "Numpad9", + "NumpadEnter", + + "Space", +]); diff --git a/frontend/src/ts/constants/themes.ts b/frontend/src/ts/constants/themes.ts index 760478636c7b..0bb86f625671 100644 --- a/frontend/src/ts/constants/themes.ts +++ b/frontend/src/ts/constants/themes.ts @@ -1,5 +1,4 @@ import { ThemeName } from "@monkeytype/schemas/configs"; -import { hexToHSL } from "../utils/colors"; import { z } from "zod"; const hexColorSchema = z @@ -2335,11 +2334,3 @@ export const ThemesList: ThemeWithName[] = Object.keys(themes) name: it as ThemeName, }) as Theme & { name: ThemeName }, ); - -export const ThemesListSorted: ThemeWithName[] = [ - ...ThemesList.sort((a, b) => { - const b1 = hexToHSL(a.bg); - const b2 = hexToHSL(b.bg); - return b2.lgt - b1.lgt; - }), -]; diff --git a/frontend/src/ts/utils/typo-list.ts b/frontend/src/ts/constants/typo-list.ts similarity index 100% rename from frontend/src/ts/utils/typo-list.ts rename to frontend/src/ts/constants/typo-list.ts diff --git a/frontend/src/ts/elements/settings/theme-picker.ts b/frontend/src/ts/elements/settings/theme-picker.ts index 4dc6538965e6..93c3a5d89b12 100644 --- a/frontend/src/ts/elements/settings/theme-picker.ts +++ b/frontend/src/ts/elements/settings/theme-picker.ts @@ -14,10 +14,16 @@ import { isAuthenticated } from "../../firebase"; import { getActivePage } from "../../signals/core"; import { ThemeName } from "@monkeytype/schemas/configs"; import { captureException } from "../../sentry"; -import { ColorName, ThemesListSorted } from "../../constants/themes"; +import { ColorName, ThemesList, ThemeWithName } from "../../constants/themes"; import { qs, qsa, qsr } from "../../utils/dom"; import { getTheme, updateThemeColor } from "../../signals/theme"; +export const sortedThemes: ThemeWithName[] = [...ThemesList].sort((a, b) => { + const b1 = Colors.hexToHSL(a.bg); + const b2 = Colors.hexToHSL(b.bg); + return b2.lgt - b1.lgt; +}); + function updateActiveButton(): void { let activeThemeName: string = Config.theme; if ( @@ -85,7 +91,7 @@ export async function fillPresetButtons(): Promise { activeThemeName = ThemeController.randomTheme; } - const themes = ThemesListSorted; + const themes = sortedThemes; //first show favourites if (Config.favThemes.length > 0) { diff --git a/frontend/src/ts/input/handlers/keydown.ts b/frontend/src/ts/input/handlers/keydown.ts index 647c55cadad1..4eabb48b2258 100644 --- a/frontend/src/ts/input/handlers/keydown.ts +++ b/frontend/src/ts/input/handlers/keydown.ts @@ -26,6 +26,7 @@ import { getActiveFunboxesWithFunction, getActiveFunboxNames, } from "../../test/funbox/list"; +import { Keycode } from "../../constants/keys"; export async function handleTab(e: KeyboardEvent, now: number): Promise { if (Config.quickRestart === "tab") { @@ -122,7 +123,7 @@ export async function handleOppositeShift(event: KeyboardEvent): Promise { ); } else { setCorrectShiftUsed( - ShiftTracker.isUsingOppositeShift(event.code as KeyConverter.Keycode), + ShiftTracker.isUsingOppositeShift(event.code as Keycode), ); } } diff --git a/frontend/src/ts/pages/login.ts b/frontend/src/ts/pages/login.ts index d546b02409fd..299bba8ddb5f 100644 --- a/frontend/src/ts/pages/login.ts +++ b/frontend/src/ts/pages/login.ts @@ -1,7 +1,7 @@ import Ape from "../ape"; import Page from "./page"; import * as Skeleton from "../utils/skeleton"; -import TypoList from "../utils/typo-list"; +import TypoList from "../constants/typo-list"; import { PasswordSchema, UserEmailSchema, diff --git a/frontend/src/ts/test/british-english.ts b/frontend/src/ts/test/british-english.ts index 4c7c51a4948d..3875d82e3bb8 100644 --- a/frontend/src/ts/test/british-english.ts +++ b/frontend/src/ts/test/british-english.ts @@ -1,686 +1,7 @@ import Config from "../config"; +import britishEnglishReplacements from "../constants/british-english"; import { capitalizeFirstLetterOfEachWord } from "../utils/strings"; -type ExceptionRule = { britishWord: string; exceptPreviousWords: string[] }; -type BritishEnglishReplacements = Record< - string /*EnglishWord*/, - string /*BritishWord*/ | ExceptionRule ->; -const replacementRules: BritishEnglishReplacements = { - laborers: "labourers", - industrialized: "industrialised", - acclimatizing: "acclimatising", - acclimatized: "acclimatised", - behoove: "behove", - reorganization: "reorganisation", - galvanize: "galvanise", - demagogism: "demagoguism", - canceled: "cancelled", - baptize: "baptise", - revitalize: "revitalise", - skeptical: "sceptical", - piscine: "piscinae", - ionization: "ionisation", - chili: "chilli", - dexterous: "dextrous", - likable: "likeable", - neutralize: "neutralise", - meter: "metre", - meters: "metres", - centimeter: "centimetre", - hurrah: "hooray", - multicolor: "multicolour", - actualization: "actualisation", - fertilizing: "fertilising", - enamor: "enamour", - skepticism: "scepticism", - authorize: "authorise", - minimize: "minimise", - bandoleer: "bandolier", - rigor: "rigour", - fledgling: "fledgeling", - mesquite: "mesquit", - fogy: "fogey", - characterize: "characterise", - wagonette: "waggonette", - plagiarize: "plagiarise", - kilometers: "kilometres", - molt: "moult", - leveler: "leveller", - checkered: "chequered", - vendor: "vender", - candor: "candour", - moralize: "moralise", - denationalization: "denationalisation", - anemia: "anaemia", - caiman: "cayman", - chitterlings: "chitlins", - acclimated: "acclimatised", - acclimate: "acclimatise", - skillful: "skilful", - enamored: "enamoured", - watercolor: "watercolour", - extemporization: "extemporisation", - lackluster: "lacklustre", - equalizer: "equaliser", - cipher: "cypher", - polarization: "polarisation", - polymerization: "polymerisation", - ionize: "ionise", - anesthetic: "anaesthetic", - aerie: "eyrie", - lachrymal: "lacrimal", - decimeter: "decimetre", - rajah: "raja", - modernize: "modernise", - gasoline: "petrol", - alphabetized: "alphabetised", - saber: "sabre", - burglarize: "burglarise", - terrorize: "terrorise", - enthrall: "enthral", - mustachioed: "moustachioed", - anesthesia: "anaesthesia", - sepulcher: "sepulchre", - caftan: "kaftan", - organize: "organise", - manikin: "mannikin", - dexterously: "dextrously", - artifact: "artefact", - kilometer: "kilometre", - mommy: "mummy", - brant: "brent", - hyena: "hyaena", - fuze: "fuse", - victimize: "victimise", - jihad: "jehad", - airplane: "aeroplane", - laborer: "labourer", - vaporware: "vapourware", - worshiped: "worshipped", - taboret: "tabouret", - rationalize: "rationalise", - whimsy: "whimsey", - scandalize: "scandalise", - categorization: "categorisation", - centered: "centred", - kerosene: "kerosine", - specialize: "specialise", - specialized: "specialised", - cicatrix: "cicatrice", - jailer: "jailor", - unfavorable: "unfavourable", - guerrilla: "guerilla", - emphasize: "emphasise", - wacky: "whacky", - ionizing: "ionising", - czarina: "tzarina", - ratline: "ratlin", - abolitionize: "abolitionise", - subsidize: "subsidise", - plowing: "ploughing", - untrammeled: "untrammelled", - worshiping: "worshipping", - memorization: "memorisation", - anglicize: "anglicise", - finalize: "finalise", - gases: "gasses", - fertilization: "fertilisation", - libeling: "libelling", - kinesthetic: "kinaesthetic", - immunization: "immunisation", - coloration: "colouration", - overdraft: "overdraught", - lambaste: "lambast", - unpasteurized: "unpasteurised", - ascendance: "ascendence", - jeweler: "jeweller", - fervor: "fervour", - jeopardize: "jeopardise", - abridgment: "abridgement", - monopolize: "monopolise", - colorless: "colourless", - colorlessness: "colourlessness", - tumors: "tumours", - jinni: "jinn", - aluminum: "aluminium", - salable: "saleable", - bronco: "broncho", - lupine: "lupin", - linchpin: "lynchpin", - mesmerize: "mesmerise", - internationalization: "internationalisation", - anapestic: "anapaestic", - supersede: "supercede", - europeanize: "europeanise", - optimized: "optimised", - botanize: "botanise", - organizational: "organisational", - heme: "haem", - estivation: "aestivation", - edema: "oedema", - penalize: "penalise", - peddler: "pedlar", - biased: "biassed", - aggrandize: "aggrandise", - rationalizing: "rationalising", - deputize: "deputise", - centers: "centres", - unicolor: "unicolour", - hypnotized: "hypnotised", - anglicized: "anglicised", - initialization: "initialisation", - topee: "topi", - nightie: "nighty", - tricolor: "tricolour", - reorganize: "reorganise", - barbecue: "barbeque", - fertilized: "fertilised", - synthesize: "synthesise", - economize: "economise", - colter: "coulter", - paleontologist: "palaeontologist", - acclimatize: "acclimatise", - idealize: "idealise", - fossilization: "fossilisation", - lionize: "lionise", - acclimating: "acclimatising", - luster: "lustre", - demeanor: "demeanour", - unauthorized: "unauthorised", - smolder: "smoulder", - abettor: "abetter", - jewelry: "jewellery", - demoralization: "demoralisation", - fullness: "fulness", - neighbored: "neighboured", - neighbor: "neighbour", - neighbors: "neighbours", - neighboring: "neighbouring", - neighborly: "neighbourly", - neighborhood: "neighbourhood", - neighborhoods: "neighbourhoods", - magnetizer: "magnetiser", - appetizer: "appetiser", - hebraizing: "hebraising", - carbonization: "carbonisation", - favorably: "favourably", - favorite: "favourite", - behavioral: "behavioural", - cognizant: "cognisant", - skeptic: "sceptic", - fiber: "fibre", - fibers: "fibres", - labeled: "labelled", - analyze: "analyse", - disorganization: "disorganisation", - concenter: "concentre", - categorize: "categorise", - novelization: "novelisation", - proselytize: "proselytise", - draftsman: "draughtsman", - paralyze: "paralyse", - ostracize: "ostracise", - italicize: "italicise", - micrometer: "micrometre", - cognizance: "cognisance", - saltpeter: "saltpetre", - conceptualization: "conceptualisation", - containerization: "containerisation", - anapest: "anapaest", - leukemia: "leukaemia", - omelet: "omelette", - industrialize: "industrialise", - characterization: "characterisation", - amortize: "amortise", - mazurka: "mazourka", - macadamize: "macadamise", - stymie: "stymy", - analog: "analogue", - prizer: "priser", - cauterize: "cauterise", - dysmenorrhea: "dysmenorrhoea", - hippie: "hippy", - mechanization: "mechanisation", - commercialize: "commercialise", - unsavory: "unsavoury", - somber: "sombre", - esophageal: "oesophageal", - iodized: "iodised", - tyrannize: "tyrannise", - liberalize: "liberalise", - computerization: "computerisation", - synthesizer: "synthesiser", - fertilizes: "fertilises", - airdrome: "aerodrome", - uncivilized: "uncivilised", - mold: "mould", - nitrogenized: "nitrogenised", - legalize: "legalise", - tantalize: "tantalise", - eulogize: "eulogise", - depolarization: "depolarisation", - fecal: "faecal", - bastardize: "bastardise", - summarize: "summarise", - cony: "coney", - authorization: "authorisation", - colorful: "colourful", - temporized: "temporised", - adviser: "advisor", - tendinitis: "tendonitis", - crystallization: "crystallisation", - humor: "humour", - humorous: "humourous", - chanty: "shanty", - dyspnea: "dyspnoea", - aging: "ageing", - mousy: "mousey", - succor: "succour", - distill: "distil", - decentralization: "decentralisation", - cauterization: "cauterisation", - specter: "spectre", - snowplow: "snowplough", - pediatrics: "paediatrics", - discoloration: "discolouration", - tumor: "tumour", - empathize: "empathise", - pawpaw: "papaya", - aggrandizement: "aggrandisement", - fontanel: "fontanelle", - brunet: "brunette", - rumor: "rumour", - epaulet: "epaulette", - glycerin: "glycerine", - fraternize: "fraternise", - latinize: "latinise", - sniveling: "snivelling", - pasteurize: "pasteurise", - modernization: "modernisation", - patronize: "patronise", - totaled: "totalled", - normalization: "normalisation", - niter: "nitre", - shoveler: "shoveller", - flier: "flyer", - equalization: "equalisation", - meagerly: "meagrely", - favoritism: "favouritism", - libelous: "libellous", - popularized: "popularised", - armory: "armoury", - humanization: "humanisation", - minuscule: "miniscule", - collectible: "collectable", - tepee: "teepee", - stabilization: "stabilisation", - moldy: "mouldy", - colonize: "colonise", - idealized: "idealised", - meager: "meagre", - armorer: "armourer", - vitalize: "vitalise", - fossilized: "fossilised", - antagonize: "antagonise", - criticize: "criticise", - liter: "litre", - stigmatize: "stigmatise", - theorize: "theorise", - combated: "combatted", - desalination: "desalinisation", - evangelize: "evangelise", - idolization: "idolisation", - smoldering: "smouldering", - commercialization: "commercialisation", - laureled: "laurelled", - hematology: "haematology", - fulfill: "fulfil", - disorganized: "disorganised", - accouterments: "accoutrements", - busses: "buses", - utilize: "utilise", - enroll: "enrol", - goiter: "goitre", - stylized: "stylised", - diarrhea: "diarrhoea", - hypothesize: "hypothesise", - esthetic: "aesthetic", - dishonor: "dishonour", - victualer: "victualler", - paleolithic: "palaeolithic", - sanatorium: "sanitarium", - feminization: "feminisation", - flotation: "floatation", - teetotaler: "teetotaller", - feudalization: "feudalisation", - visualize: "visualise", - fertilize: "fertilise", - czar: "tzar", - nationalization: "nationalisation", - septicemia: "septicaemia", - organizer: "organiser", - recrystallization: "recrystallisation", - dolor: "dolour", - agonizing: "agonising", - romanization: "romanisation", - synchronize: "synchronise", - amorist: "amourist", - agonized: "agonised", - belabor: "belabour", - caster: "castor", - softy: "softie", - apothegm: "apophthegm", - demobilization: "demobilisation", - agonizes: "agonises", - misdemeanor: "misdemeanour", - recognizable: "recognisable", - asshole: "arsehole", - brutalization: "brutalisation", - chamois: "shammy", - clamor: "clamour", - fertilizer: "fertiliser", - deodorization: "deodorisation", - privatization: "privatisation", - tidbit: "titbit", - molding: "moulding", - alleluia: "halleluiah", - canonization: "canonisation", - customize: "customise", - customization: "customisations", - customizer: "customiser", - customizers: "customisers", - customizes: "customises", - customizing: "customising", - popularize: "popularise", - specialty: "speciality", - meagerness: "meagreness", - esophagus: "oesophagus", - millimeter: "millimetre", - harmonization: "harmonisation", - atomizer: "atomiser", - dieresis: "diaeresis", - maneuver: "manoeuvre", - capitalize: "capitalise", - gynecologist: "gynaecologist", - acclimation: "acclimatisation", - generalize: "generalise", - temporize: "temporise", - premunire: "praemunire", - estival: "aestival", - selvage: "selvedge", - brier: "briar", - hyperesthesia: "hyperaesthesia", - maximize: "maximise", - draftsmen: "draughtsmen", - colonization: "colonisation", - capitalization: "capitalisation", - tenia: "taenia", - paleontology: "palaeontology", - libeler: "libeller", - arytenoid: "arytaenoid", - wainscoting: "wainscotting", - globalization: "globalisation", - legalization: "legalisation", - magnetization: "magnetisation", - stabilize: "stabilise", - mesmerized: "mesmerised", - savory: "savoury", - reconnoiter: "reconnoitre", - bastardized: "bastardised", - rancor: "rancour", - checker: "chequer", - industrialization: "industrialisation", - epitomize: "epitomise", - socialize: "socialise", - externalization: "externalisation", - chivy: "chivvy", - optimize: "optimise", - romanize: "romanise", - vulcanize: "vulcanise", - plow: "plough", - memorize: "memorise", - sterilization: "sterilisation", - routing: "routeing", - raveling: "ravelling", - savor: "savour", - harmonize: "harmonise", - cannibalize: "cannibalise", - vaporize: "vaporise", - utilization: "utilisation", - hybridization: "hybridisation", - mechanize: "mechanise", - arbor: "arbour", - arbors: "arbours", - licorice: "liquorice", - counselor: "counsellor", - orthopedic: "orthopaedic", - lusterless: "lustreless", - numskull: "numbskull", - paleozoic: "palaeozoic", - malodor: "malodour", - amenorrhea: "amenorrhoea", - criticized: "criticised", - gonorrhea: "gonorrhoea", - fossilize: "fossilise", - revolutionize: "revolutionise", - woolen: "woollen", - dishabille: "deshabille", - organdy: "organdie", - asses: "arses", - furor: "furore", - paycheck: "paycheque", - pulverize: "pulverise", - dramatization: "dramatisation", - yodeler: "yodeller", - apologize: "apologise", - apologized: "apologised", - blond: "blonde", - oxidize: "oxidise", - extemporize: "extemporise", - whiz: "whizz", - edile: "aedile", - appall: "appal", - legitimize: "legitimise", - urbanization: "urbanisation", - magnetize: "magnetise", - womanize: "womanise", - orthopedics: "orthopaedics", - cognize: "cognise", - christianization: "christianisation", - vocalize: "vocalise", - individualization: "individualisation", - hemoglobin: "haemoglobin", - racket: "racquet", - agonize: "agonise", - aggrandizes: "aggrandises", - accouter: "accoutre", - mollusk: "mollusc", - publicize: "publicise", - fraternization: "fraternisation", - odorless: "odourless", - odor: "odour", - odorous: "odourous", - rationalization: "rationalisation", - pretense: "pretence", - louver: "louvre", - kopeck: "kopek", - lissome: "lissom", - idealization: "idealisation", - nosy: "nosey", - stogie: "stogy", - althea: "althaea", - immobilization: "immobilisation", - majolica: "maiolica", - savior: "saviour", - civilize: "civilise", - granddad: "grandad", - centralization: "centralisation", - localization: "localisation", - evangelization: "evangelisation", - ruble: "rouble", - pajamas: "pyjamas", - sterilize: "sterilise", - math: "maths", - localize: "localise", - hospitalization: "hospitalisation", - scrutinize: "scrutinise", - acclimatization: "acclimatisation", - misbehavior: "misbehaviour", - behavior: "behaviour", - color: "colour", - tire: { britishWord: "tyre", exceptPreviousWords: ["will"] }, - gray: "grey", - grays: "greys", - theater: "theatre", - amphitheater: "amphitheatre", - center: "centre", - realize: "realise", - realizing: "realising", - realization: "realisation", - license: "licence", - mom: "mum", - "mom'l": "mum'll", - favor: "favour", - favors: "favours", - favorites: "favourites", - analyzed: "analysed", - characterized: "characterised", - colored: "coloured", - colors: "colours", - counseling: "counselling", - customized: "customised", - defense: "defence", - offense: "offence", - enrollment: "enrolment", - flavor: "flavour", - flavors: "flavours", - flavoring: "flavouring", - harbor: "harbour", - harbored: "harboured", - honor: "honour", - honors: "honours", - labor: "labour", - licensed: "licenced", - licenses: "licences", - licensing: "licencing", - modeling: "modelling", - optimization: "optimisation", - organization: "organisation", - organizations: "organisations", - organized: "organised", - organizing: "organising", - pediatric: "paediatric", - personalized: "personalised", - practice: "practise", - realized: "realised", - recognize: "recognise", - recognized: "recognised", - specialties: "specialities", - specializing: "specialising", - theaters: "theatres", - travelers: "travellers", - traveler: "traveller", - traveling: "travelling", - authorized: "authorised", - behaviors: "behaviours", - traveled: "travelled", - utilizing: "utilising", - utilized: "utilised", - honored: "honoured", - specializes: "specialises", - practicing: "practising", - signaling: "signalling", - analyzing: "analysing", - recognizes: "recognises", - organizers: "organisers", - visualization: "visualisation", - standardized: "standardised", - favorable: "favourable", - analyzer: "analyser", - recognizing: "recognising", - uncategorized: "uncategorised", - categorized: "categorised", - vapor: "vapour", - synchronization: "synchronisation", - synchronized: "synchronised", - rumors: "rumours", - coloring: "colouring", - honorable: "honourable", - generalized: "generalised", - generalization: "generalisation", - mobilize: "mobilise", - armor: "armour", - armored: "armoured", - labeling: "labelling", - endeavor: "endeavour", - civilized: "civilised", - civilization: "civilisation", - parlor: "parlour", - tranquilize: "tranquilise", - tranquillized: "tranquillised", - tranquillization: "tranquillisation", - catalog: "catalogue", - cataloger: "cataloguer", - cataloging: "cataloguing", - catalogs: "catalogues", - cataloged: "catalogued", - uncataloged: "uncatalogued", - catalogers: "cataloguers", - discolored: "discoloured", - discolor: "discolour", - encyclopedias: "encyclopaedias", - endeavored: "endeavoured", - endeavors: "endeavours", - endeavoring: "endeavouring", - judgments: "judgements", - judgment: "judgement", - paneling: "panelling", - defenses: "defences", - criticizing: "criticising", - mustache: "moustache", - emphasized: "emphasised", - emphasizes: "emphasises", - emphasizing: "emphasising", - fetus: "foetus", - programs: "programmes", - yogurt: "yoghurt", - valor: "valour", - moisturize: "moisturise", - moisturized: "moisturised", - moisturizes: "moisturises", - moisturizing: "moisturising", - favoring: "favouring", - marvelous: "marvellous", - hematuria: "haematuria", - hemoptysis: "haemoptysis", - hemorrhoid: "haemorrhoid", - hemorrhagic: "haemorrhagic", - hypercalcemia: "hypercalcaemia", - hyperglycemia: "hyperglycaemia", - hypoglycemia: "hypoglycaemia", - toxemia: "toxaemia", - hypoxemia: "hypoxaemia", - bacteremia: "bacteraemia", - hypernatremia: "hypernatraemia", - hyponatremia: "hyponatraemia", - leukocytosis: "leucocytosis", - leukocyte: "leucocyte", - leukopenia: "leucopenia", - apnea: "apnoea", - bradypnea: "bradypnoea", - tachypnea: "tachypnoea", - orthopnea: "orthopnoea", - ileocecal: "ileocaecal", - metastasize: "metastasise", - lymphedema: "lymphoedema", - neuron: "neurone", - hemianopsia: "hemianopia", - galactorrhea: "galactorrhoea", - nebulizer: "nebuliser", - paresthesia: "paraesthesia", -}; - export async function replace( word: string, previousWord: string, @@ -700,10 +21,15 @@ export async function replace( ).join("-"); } else { const cleanedWord = word.replace(/^[\W]+|[\W]+$/g, "").toLowerCase(); - if (!Object.prototype.hasOwnProperty.call(replacementRules, cleanedWord)) { + if ( + !Object.prototype.hasOwnProperty.call( + britishEnglishReplacements, + cleanedWord, + ) + ) { return word; } - const rule = replacementRules[cleanedWord]; + const rule = britishEnglishReplacements[cleanedWord]; if (rule === undefined) return word; diff --git a/frontend/src/ts/test/monkey.ts b/frontend/src/ts/test/monkey.ts index 17a19ba8adab..713b8002f1ce 100644 --- a/frontend/src/ts/test/monkey.ts +++ b/frontend/src/ts/test/monkey.ts @@ -4,6 +4,7 @@ import * as ConfigEvent from "../observables/config-event"; import * as TestState from "../test/test-state"; import * as KeyConverter from "../utils/key-converter"; import { qs } from "../utils/dom"; +import { Keycode } from "../constants/keys"; const monkeyEl = qs("#monkey"); const monkeyFastEl = qs("#monkey .fast"); @@ -63,7 +64,7 @@ export function type(event: KeyboardEvent): void { if (!Config.monkey) return; const { leftSide, rightSide } = KeyConverter.keycodeToKeyboardSide( - event.code as KeyConverter.Keycode, + event.code as Keycode, ); if (leftSide && rightSide) { // if its a middle key handle special case @@ -101,7 +102,7 @@ export function stop(event: KeyboardEvent): void { if (!Config.monkey) return; const { leftSide, rightSide } = KeyConverter.keycodeToKeyboardSide( - event.code as KeyConverter.Keycode, + event.code as Keycode, ); if (leftSide && rightSide) { // if middle key handle special case diff --git a/frontend/src/ts/test/shift-tracker.ts b/frontend/src/ts/test/shift-tracker.ts index 90a7feea29a5..9e9120e21c37 100644 --- a/frontend/src/ts/test/shift-tracker.ts +++ b/frontend/src/ts/test/shift-tracker.ts @@ -1,4 +1,5 @@ import Config from "../config"; +import { Keycode } from "../constants/keys"; import * as KeyConverter from "../utils/key-converter"; export let leftState = false; @@ -26,7 +27,7 @@ export function reset(): void { rightState = false; } -export function isUsingOppositeShift(keycode: KeyConverter.Keycode): boolean { +export function isUsingOppositeShift(keycode: Keycode): boolean { if (!leftState && !rightState) { return true; } diff --git a/frontend/src/ts/utils/key-converter.ts b/frontend/src/ts/utils/key-converter.ts index 328f0f144700..69f96220a6ed 100644 --- a/frontend/src/ts/utils/key-converter.ts +++ b/frontend/src/ts/utils/key-converter.ts @@ -1,233 +1,10 @@ import { LayoutObject } from "@monkeytype/schemas/layouts"; - -export type Keycode = - | "Backquote" - | "Digit1" - | "Digit2" - | "Digit3" - | "Digit4" - | "Digit5" - | "Digit6" - | "Digit7" - | "Digit8" - | "Digit9" - | "Digit0" - | "Minus" - | "Equal" - | "KeyQ" - | "KeyW" - | "KeyE" - | "KeyR" - | "KeyT" - | "KeyY" - | "KeyU" - | "KeyI" - | "KeyO" - | "KeyP" - | "BracketLeft" - | "BracketRight" - | "Backslash" - | "KeyA" - | "KeyS" - | "KeyD" - | "KeyF" - | "KeyG" - | "KeyH" - | "KeyJ" - | "KeyK" - | "KeyL" - | "Semicolon" - | "Quote" - | "KeyZ" - | "KeyX" - | "KeyC" - | "KeyV" - | "KeyB" - | "KeyN" - | "KeyM" - | "Comma" - | "Period" - | "Slash" - | "Space" - | "ShiftLeft" - | "IntlBackslash" - | "ShiftRight" - | "ArrowUp" - | "ArrowLeft" - | "ArrowDown" - | "ArrowRight" - | "NumpadMultiply" - | "NumpadSubtract" - | "NumpadAdd" - | "NumpadDecimal" - | "NumpadEqual" - | "NumpadDivide" - | "Numpad0" - | "Numpad1" - | "Numpad2" - | "Numpad3" - | "Numpad4" - | "Numpad5" - | "Numpad6" - | "Numpad7" - | "Numpad8" - | "Numpad9" - | "NumpadEnter" - | "Enter" - | "Backspace"; - -const qwertyKeycodeKeymap: Keycode[][] = [ - [ - "Backquote", - "Digit1", - "Digit2", - "Digit3", - "Digit4", - "Digit5", - "Digit6", - "Digit7", - "Digit8", - "Digit9", - "Digit0", - "Minus", - "Equal", - ], - [ - "KeyQ", - "KeyW", - "KeyE", - "KeyR", - "KeyT", - "KeyY", - "KeyU", - "KeyI", - "KeyO", - "KeyP", - "BracketLeft", - "BracketRight", - "Backslash", - ], - [ - "KeyA", - "KeyS", - "KeyD", - "KeyF", - "KeyG", - "KeyH", - "KeyJ", - "KeyK", - "KeyL", - "Semicolon", - "Quote", - ], - [ - "KeyZ", - "KeyX", - "KeyC", - "KeyV", - "KeyB", - "KeyN", - "KeyM", - "Comma", - "Period", - "Slash", - ], - ["Space"], -]; - -const leftSideKeys: Set = new Set([ - "Backquote", - "Digit1", - "Digit2", - "Digit3", - "Digit4", - "Digit5", - "Digit6", - - "KeyQ", - "KeyW", - "KeyE", - "KeyR", - "KeyT", - "KeyY", - - "KeyA", - "KeyS", - "KeyD", - "KeyF", - "KeyG", - - "ShiftLeft", - "IntlBackslash", - "KeyZ", - "KeyX", - "KeyC", - "KeyV", - "KeyB", - - "Space", -]); - -const rightSideKeys: Set = new Set([ - "Digit6", - "Digit7", - "Digit8", - "Digit9", - "Digit0", - "Minus", - "Equal", - "Backspace", - - "KeyY", - "KeyU", - "KeyI", - "KeyO", - "KeyP", - "BracketLeft", - "BracketRight", - "Backslash", - - "KeyH", - "KeyJ", - "KeyK", - "KeyL", - "Semicolon", - "Quote", - "Enter", - - "KeyB", - "KeyN", - "KeyM", - "Comma", - "Period", - "Slash", - "ShiftRight", - - "ArrowUp", - "ArrowLeft", - "ArrowDown", - "ArrowRight", - - "NumpadMultiply", - "NumpadSubtract", - "NumpadAdd", - "NumpadDecimal", - "NumpadEqual", - "NumpadDivide", - "Numpad0", - "Numpad1", - "Numpad2", - "Numpad3", - "Numpad4", - "Numpad5", - "Numpad6", - "Numpad7", - "Numpad8", - "Numpad9", - "NumpadEnter", - - "Space", -]); +import { + Keycode, + leftSideKeys, + qwertyKeycodeKeymap, + rightSideKeys, +} from "../constants/keys"; /** * Converts a key to a keycode based on a layout diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 12ec8107af79..4438746fffa8 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -263,6 +263,10 @@ function getBuildOptions({ name: "vendor-chart", test: /node_modules\/chart/, }, + { + name: "monkeytype-constants", + test: /src\/ts\/constants\//, + }, { name: "vendor", test: /node_modules\//,