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

cleaning up styles and code #2206

Merged
merged 1 commit into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions ui/balance_druid/sim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class BalanceDruidSimUI extends IndividualSimUI<Spec.SpecBalanceDruid> {
constructor(parentElem: HTMLElement, player: Player<Spec.SpecBalanceDruid>) {
super(parentElem, player, {
cssClass: 'balance-druid-sim-ui',
cssScheme: 'druid',
// List any known bugs / issues here and they'll be shown on the site.
knownIssues: [
],
Expand Down
4 changes: 2 additions & 2 deletions ui/core/components/detailed_results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export class DetailedResults extends Component {
const computedStyles = window.getComputedStyle(this.rootElem);

const url = new URL(`${window.location.protocol}//${window.location.host}/${REPO_NAME}/detailed_results/index.html`);
url.searchParams.append('cssScheme', simUI.cssScheme);
url.searchParams.append('mainTextColor', computedStyles.getPropertyValue('--main-text-color').trim());
url.searchParams.append('themeColorPrimary', computedStyles.getPropertyValue('--theme-color-primary').trim());
url.searchParams.append('themeColorBackground', computedStyles.getPropertyValue('--theme-color-background').trim());
url.searchParams.append('themeColorBackgroundRaw', computedStyles.getPropertyValue('--theme-color-background-raw').trim());
url.searchParams.append('themeBackgroundImage', computedStyles.getPropertyValue('--theme-background-image').trim());
Expand All @@ -36,7 +36,7 @@ export class DetailedResults extends Component {

this.rootElem.innerHTML = `
<div class="detailed-results-controls-div">
<button class="detailed-results-new-tab-button sim-button">VIEW IN SEPARATE TAB</button>
<button class="detailed-results-new-tab-button btn btn-${this.simUI.cssScheme}">View in Separate Tab</button>
</div>
<iframe class="detailed-results-iframe" src="${url.href}" allowtransparency="true"></iframe>
`;
Expand Down
8 changes: 4 additions & 4 deletions ui/core/components/encounter_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ export class EncounterPicker extends Component {
}

const advancedButton = document.createElement('button');
advancedButton.classList.add('advanced-button', 'btn', 'btn-primary');
advancedButton.classList.add('advanced-button', 'btn', `btn-${simUI.cssScheme}`);
advancedButton.textContent = 'Advanced';
advancedButton.addEventListener('click', () => new AdvancedEncounterModal(this.rootElem, modEncounter, simUI));
advancedButton.addEventListener('click', () => new AdvancedEncounterModal(this.rootElem, simUI, modEncounter));
this.rootElem.appendChild(advancedButton);
});
}
Expand All @@ -132,7 +132,7 @@ export class EncounterPicker extends Component {
class AdvancedEncounterModal extends BaseModal {
private readonly encounter: Encounter;

constructor(parent: HTMLElement, encounter: Encounter, simUI: SimUI) {
constructor(parent: HTMLElement, simUI: SimUI, encounter: Encounter) {
super('advanced-encounter-picker-modal');

this.encounter = encounter;
Expand Down Expand Up @@ -160,7 +160,7 @@ class AdvancedEncounterModal extends BaseModal {
},
});
}
new ListPicker<Encounter, Target, TargetPicker>(targetsElem, this.encounter, {
new ListPicker<Encounter, Target, TargetPicker>(targetsElem, simUI, this.encounter, {
extraCssClasses: ['targets-picker', 'mb-0'],
itemLabel: 'Target',
changedEvent: (encounter: Encounter) => encounter.targetsChangeEmitter,
Expand Down
48 changes: 20 additions & 28 deletions ui/core/components/exporters.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
import { Class } from '../proto/common.js';
import { EquipmentSpec } from '../proto/common.js';
import { ItemSpec } from '../proto/common.js';
import { Race } from '../proto/common.js';
import { Spec } from '../proto/common.js';
import { Stat, PseudoStat } from '../proto/common.js';
import { IndividualSimSettings } from '../proto/ui.js';
import { IndividualSimUI } from '../individual_sim_ui.js';
import { Player } from '../player.js';
import { UnitStat } from '../proto_utils/stats.js';
import { classNames, nameToClass, nameToRace } from '../proto_utils/names.js';
import { specNames } from '../proto_utils/utils.js';
import { talentSpellIdsToTalentString } from '../talents/factory.js';
import { EventID, TypedEvent } from '../typed_event.js';
import { downloadString, getEnumValues } from '../utils.js';

import { Popup } from './popup.js';

declare var $: any;
declare var tippy: any;
declare var pako: any;
import { Popup } from './popup';
import { IndividualSimUI } from '../individual_sim_ui';
import { SimUI } from '../sim_ui';
import {
PseudoStat,
Spec,
Stat
} from '../proto/common';
import { IndividualSimSettings } from '../proto/ui';
import { classNames } from '../proto_utils/names';
import { UnitStat } from '../proto_utils/stats';
import { specNames } from '../proto_utils/utils';
import { downloadString } from '../utils';

export abstract class Exporter extends Popup {
private readonly textElem: HTMLElement;

constructor(parent: HTMLElement, title: string, allowDownload: boolean) {
constructor(parent: HTMLElement, simUI: SimUI, title: string, allowDownload: boolean) {
super(parent);

this.rootElem.classList.add('exporter');
Expand All @@ -33,8 +25,8 @@ export abstract class Exporter extends Popup {
<textarea class="exporter-textarea form-control" readonly></textarea>
</div>
<div class="actions-row">
<button class="exporter-button btn btn-primary clipboard-button">COPY TO CLIPBOARD</button>
<button class="exporter-button btn btn-primary download-button">DOWNLOAD</button>
<button class="exporter-button btn btn-${simUI.cssScheme} clipboard-button">COPY TO CLIPBOARD</button>
<button class="exporter-button btn btn-${simUI.cssScheme} download-button">DOWNLOAD</button>
</div>
`;

Expand Down Expand Up @@ -74,7 +66,7 @@ export class IndividualLinkExporter<SpecType extends Spec> extends Exporter {
private readonly simUI: IndividualSimUI<SpecType>;

constructor(parent: HTMLElement, simUI: IndividualSimUI<SpecType>) {
super(parent, 'Sharable Link', false);
super(parent, simUI, 'Sharable Link', false);
this.simUI = simUI;
this.init();
}
Expand All @@ -88,7 +80,7 @@ export class IndividualJsonExporter<SpecType extends Spec> extends Exporter {
private readonly simUI: IndividualSimUI<SpecType>;

constructor(parent: HTMLElement, simUI: IndividualSimUI<SpecType>) {
super(parent, 'JSON Export', true);
super(parent, simUI, 'JSON Export', true);
this.simUI = simUI;
this.init();
}
Expand All @@ -102,7 +94,7 @@ export class Individual80UEPExporter<SpecType extends Spec> extends Exporter {
private readonly simUI: IndividualSimUI<SpecType>;

constructor(parent: HTMLElement, simUI: IndividualSimUI<SpecType>) {
super(parent, '80Upgrades EP Export', true);
super(parent, simUI, '80Upgrades EP Export', true);
this.simUI = simUI;
this.init();
}
Expand Down Expand Up @@ -189,7 +181,7 @@ export class IndividualPawnEPExporter<SpecType extends Spec> extends Exporter {
private readonly simUI: IndividualSimUI<SpecType>;

constructor(parent: HTMLElement, simUI: IndividualSimUI<SpecType>) {
super(parent, 'Pawn EP Export', true);
super(parent, simUI, 'Pawn EP Export', true);
this.simUI = simUI;
this.init();
}
Expand Down
30 changes: 17 additions & 13 deletions ui/core/components/gear_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { makeShow1hWeaponsSelector } from './other_inputs.js';
import { makeShow2hWeaponsSelector } from './other_inputs.js';
import { makeShowMatchingGemsSelector } from './other_inputs.js';
import { Input, InputConfig } from './input.js';
import { getEnvironmentData } from 'worker_threads';
import { SimUI } from '../sim_ui.js';

declare var $: any;
declare var tippy: any;
Expand All @@ -42,7 +42,7 @@ export class GearPicker extends Component {
// ItemSlot is used as the index
readonly itemPickers: Array<ItemPicker>;

constructor(parent: HTMLElement, player: Player<any>) {
constructor(parent: HTMLElement, simUI: SimUI, player: Player<any>) {
super(parent, 'gear-picker-root');

const leftSide = document.createElement('div');
Expand All @@ -63,7 +63,7 @@ export class GearPicker extends Component {
ItemSlot.ItemSlotMainHand,
ItemSlot.ItemSlotOffHand,
ItemSlot.ItemSlotRanged,
].map(slot => new ItemPicker(leftSide, player, slot));
].map(slot => new ItemPicker(leftSide, simUI, player, slot));

const rightItemPickers = [
ItemSlot.ItemSlotHands,
Expand All @@ -74,7 +74,7 @@ export class GearPicker extends Component {
ItemSlot.ItemSlotFinger2,
ItemSlot.ItemSlotTrinket1,
ItemSlot.ItemSlotTrinket2,
].map(slot => new ItemPicker(rightSide, player, slot));
].map(slot => new ItemPicker(rightSide, simUI, player, slot));

this.itemPickers = leftItemPickers.concat(rightItemPickers).sort((a, b) => a.slot - b.slot);
}
Expand All @@ -83,6 +83,7 @@ export class GearPicker extends Component {
class ItemPicker extends Component {
readonly slot: ItemSlot;

private readonly simUI: SimUI;
private readonly player: Player<any>;
private readonly iconElem: HTMLAnchorElement;
private readonly nameElem: HTMLAnchorElement;
Expand All @@ -94,10 +95,10 @@ class ItemPicker extends Component {

private _equippedItem: EquippedItem | null = null;


constructor(parent: HTMLElement, player: Player<any>, slot: ItemSlot) {
constructor(parent: HTMLElement, simUI: SimUI, player: Player<any>, slot: ItemSlot) {
super(parent, 'item-picker-root');
this.slot = slot;
this.simUI = simUI;
this.player = player;

this.rootElem.innerHTML = `
Expand Down Expand Up @@ -132,7 +133,7 @@ class ItemPicker extends Component {

const onClickStart = (event: Event) => {
event.preventDefault();
const selectorModal = new SelectorModal(this.rootElem.closest('.individual-sim-ui')!, this.player, this.slot, this._equippedItem, this._items, this._enchants, gearData);
const selectorModal = new SelectorModal(this.simUI.rootElem, this.simUI, this.player, this.slot, this._equippedItem, this._items, this._enchants, gearData);
};
const onClickEnd = (event: Event) => {
event.preventDefault();
Expand All @@ -147,12 +148,12 @@ class ItemPicker extends Component {
// Make enchant name open enchant tab.
this.enchantElem.addEventListener('click', (ev: Event) => {
ev.preventDefault();
const selectorModal = new SelectorModal(this.rootElem.closest('.individual-sim-ui')!, this.player, this.slot, this._equippedItem, this._items, this._enchants, gearData);
const selectorModal = new SelectorModal(this.simUI.rootElem, this.simUI, this.player, this.slot, this._equippedItem, this._items, this._enchants, gearData);
selectorModal.openTab(1);
});
this.enchantElem.addEventListener('touchstart', (ev: Event) => {
ev.preventDefault();
const selectorModal = new SelectorModal(this.rootElem.closest('.individual-sim-ui')!, this.player, this.slot, this._equippedItem, this._items, this._enchants, gearData);
const selectorModal = new SelectorModal(this.simUI.rootElem, this.simUI, this.player, this.slot, this._equippedItem, this._items, this._enchants, gearData);
selectorModal.openTab(1);
});
this.enchantElem.addEventListener('touchend', onClickEnd);
Expand Down Expand Up @@ -265,7 +266,7 @@ export class IconItemSwapPicker<SpecType extends Spec, ValueType> extends Input<
private _items: Array<Item> = [];
private _enchants: Array<Enchant> = [];

constructor(parent: HTMLElement, player: Player<SpecType>, slot: ItemSlot, gear: ItemSwapGear, config: InputConfig<Player<SpecType>, ValueType>) {
constructor(parent: HTMLElement, simUI: SimUI, player: Player<SpecType>, slot: ItemSlot, gear: ItemSwapGear, config: InputConfig<Player<SpecType>, ValueType>) {
super(parent, 'icon-picker-root', player, config)
this.rootElem.classList.add('icon-picker');
this.player = player;
Expand Down Expand Up @@ -298,7 +299,8 @@ export class IconItemSwapPicker<SpecType extends Spec, ValueType> extends Input<
const onClickStart = (event: Event) => {
event.preventDefault();
new SelectorModal(
this.rootElem.closest('.individual-sim-ui')!,
simUI.rootElem,
simUI,
this.player,
this.slot,
this.gear.getEquippedItem(slot),
Expand Down Expand Up @@ -396,12 +398,14 @@ interface GearData {
}

class SelectorModal extends Popup {
private readonly simUI: SimUI;
private player: Player<any>;
private readonly tabsElem: HTMLElement;
private readonly contentElem: HTMLElement;

constructor(parent: HTMLElement, player: Player<any>, slot: ItemSlot, equippedItem: EquippedItem | null, eligibleItems: Array<Item>, eligibleEnchants: Array<Enchant>, gearData: GearData) {
constructor(parent: HTMLElement, simUI: SimUI, player: Player<any>, slot: ItemSlot, equippedItem: EquippedItem | null, eligibleItems: Array<Item>, eligibleEnchants: Array<Enchant>, gearData: GearData) {
super(parent);
this.simUI = simUI;
this.player = player;

window.scrollTo({top: 0});
Expand Down Expand Up @@ -636,7 +640,7 @@ class SelectorModal extends Popup {
>
<div class="selector-modal-tab-content-header">
<input class="selector-modal-search form-control" type="text" placeholder="Search...">
<button class="selector-modal-filters-button btn btn-primary">Filters</button>
<button class="selector-modal-filters-button btn btn-${this.simUI.cssScheme}">Filters</button>
<div class="sim-input selector-modal-boolean-option selector-modal-show-1h-weapons"></div>
<div class="sim-input selector-modal-boolean-option selector-modal-show-2h-weapons"></div>
<div class="sim-input selector-modal-boolean-option selector-modal-show-matching-gems"></div>
Expand Down
50 changes: 24 additions & 26 deletions ui/core/components/importers.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
import { Class } from '../proto/common.js';
import { EquipmentSpec } from '../proto/common.js';
import { ItemSpec } from '../proto/common.js';
import { Glyphs } from '../proto/common.js';
import { Profession } from '../proto/common.js';
import { Race } from '../proto/common.js';
import { Spec } from '../proto/common.js';
import { IndividualSimSettings } from '../proto/ui.js';
import { IndividualSimUI } from '../individual_sim_ui.js';
import { Player } from '../player.js';
import { Database } from '../proto_utils/database.js';
import { classNames, nameToClass, nameToRace, nameToProfession } from '../proto_utils/names.js';
import { classGlyphsConfig, talentSpellIdsToTalentString } from '../talents/factory.js';
import { GlyphConfig } from '../talents/glyphs_picker.js';
import { EventID, TypedEvent } from '../typed_event.js';

import { Popup } from './popup.js';

declare var $: any;
declare var tippy: any;
import { Popup } from './popup';
import { IndividualSimUI } from '../individual_sim_ui';
import { SimUI } from '../sim_ui';
import { TypedEvent } from '../typed_event';
import {
Class,
EquipmentSpec,
Glyphs,
ItemSpec,
Profession,
Race,
Spec,
} from '../proto/common';
import { IndividualSimSettings } from '../proto/ui';
import { Database } from '../proto_utils/database';
import { classNames, nameToClass, nameToRace, nameToProfession } from '../proto_utils/names';
import { classGlyphsConfig, talentSpellIdsToTalentString } from '../talents/factory';
import { GlyphConfig } from '../talents/glyphs_picker';

export abstract class Importer extends Popup {
private readonly textElem: HTMLTextAreaElement;
protected readonly descriptionElem: HTMLElement;
protected readonly importButton: HTMLButtonElement;
private readonly includeFile: boolean;

constructor(parent: HTMLElement, title: string, includeFile: boolean) {
constructor(parent: HTMLElement, simUI: SimUI, title: string, includeFile: boolean) {
super(parent);
this.includeFile = includeFile;
const uploadInputId = 'upload-input-' + title.toLowerCase().replaceAll(' ', '-');
Expand All @@ -41,11 +39,11 @@ export abstract class Importer extends Popup {
<div class="actions-row">
`;
if (this.includeFile) {
htmlVal += `<label for="${uploadInputId}" class="importer-button btn btn-primary upload-button">UPLOAD FROM FILE</label>
htmlVal += `<label for="${uploadInputId}" class="importer-button btn btn-${simUI.cssScheme} upload-button">UPLOAD FROM FILE</label>
<input type="file" id="${uploadInputId}" class="importer-upload-input" hidden>
`
}
htmlVal += `<button class="importer-button btn btn-primary import-button">IMPORT</button>
htmlVal += `<button class="importer-button btn btn-${simUI.cssScheme} import-button">IMPORT</button>
</div>
`;

Expand Down Expand Up @@ -125,7 +123,7 @@ export abstract class Importer extends Popup {
export class IndividualJsonImporter<SpecType extends Spec> extends Importer {
private readonly simUI: IndividualSimUI<SpecType>;
constructor(parent: HTMLElement, simUI: IndividualSimUI<SpecType>) {
super(parent, 'JSON Import', true);
super(parent, simUI, 'JSON Import', true);
this.simUI = simUI;

this.descriptionElem.innerHTML = `
Expand Down Expand Up @@ -157,7 +155,7 @@ export class IndividualJsonImporter<SpecType extends Spec> extends Importer {
export class Individual80UImporter<SpecType extends Spec> extends Importer {
private readonly simUI: IndividualSimUI<SpecType>;
constructor(parent: HTMLElement, simUI: IndividualSimUI<SpecType>) {
super(parent, '80 Upgrades Import', true);
super(parent, simUI, '80 Upgrades Import', true);
this.simUI = simUI;

this.descriptionElem.innerHTML = `
Expand Down Expand Up @@ -215,7 +213,7 @@ export class Individual80UImporter<SpecType extends Spec> extends Importer {
export class IndividualAddonImporter<SpecType extends Spec> extends Importer {
private readonly simUI: IndividualSimUI<SpecType>;
constructor(parent: HTMLElement, simUI: IndividualSimUI<SpecType>) {
super(parent, 'Addon Import', true);
super(parent, simUI, 'Addon Import', true);
this.simUI = simUI;

this.descriptionElem.innerHTML = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { NumberPicker } from '../number_picker.js';
import { getEnumValues } from '../../utils.js';

import { Component } from '../component.js';
import { SimUI } from 'ui/core/sim_ui.js';

export interface CustomRotationPickerConfig<SpecType extends Spec, T> {
getValue: (player: Player<SpecType>) => CustomRotation,
Expand All @@ -23,13 +24,13 @@ export interface CustomRotationPickerConfig<SpecType extends Spec, T> {
}

export class CustomRotationPicker<SpecType extends Spec, T> extends Component {
constructor(parent: HTMLElement, modPlayer: Player<SpecType>, config: CustomRotationPickerConfig<SpecType, T>) {
constructor(parent: HTMLElement, simUI: SimUI, modPlayer: Player<SpecType>, config: CustomRotationPickerConfig<SpecType, T>) {
super(parent, 'custom-rotation-picker-root');

if (config.extraCssClasses)
this.rootElem.classList.add(...config.extraCssClasses);

new ListPicker<Player<SpecType>, CustomSpell, CustomSpellPicker<SpecType, T>>(this.rootElem, modPlayer, {
new ListPicker<Player<SpecType>, CustomSpell, CustomSpellPicker<SpecType, T>>(this.rootElem, simUI, modPlayer, {
extraCssClasses: ['custom-spells-picker'],
title: 'Spell Priority',
titleTooltip: 'Spells at the top of the list are prioritized first. Safely ignores untalented options.',
Expand Down
Loading