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

fix(FEC-13955): Update Demo to support light theme #24

Merged
merged 2 commits into from
May 23, 2024
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
8 changes: 8 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
// tone6: '#ebebeb',
// tone7: '#f5f5f5',
// tone8: '#ffffff',
// tone1RGB: '51, 51, 51',
// tone2RGB: '51, 51, 51',
// tone3RGB: '135, 135, 135',
// tone4RGB: '189, 189, 189',
// tone5RGB: '217, 217, 217',
// tone6RGB: '235, 235, 235',
// tone7RGB: '245, 245, 245',
// tone8RGB: '255, 255, 255',
// paperSurface: '#f5f5f5',
// elevatedSurface: '#ffffff',
// protectionSurface: '#ffffff'
Expand Down
25 changes: 1 addition & 24 deletions src/audio-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,6 @@ class AudioPlayer extends BasePlugin {
});
}

/**
* Return a hex color as an array of Red, Green and Blue values
* @param {string} color - 3 or 6 digit hex color value
* @returns {number[]} array of RGB numeric values
*/
private getColorAsRGB(color: string) {
let fullHexColor = color;
if (color.length === 4) {
fullHexColor = `#${color[1]}${color[1]}${color[2]}${color[2]}${color[3]}${color[3]}`;
}

const colorArr = fullHexColor.match(/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i);
return colorArr ? [parseInt(colorArr[1], 16), parseInt(colorArr[2], 16), parseInt(colorArr[3], 16)] : null;
}

private prepareUI() {
if (!this.colorVariablesSet) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand All @@ -66,22 +51,14 @@ class AudioPlayer extends BasePlugin {
// @ts-ignore
this.eventManager.listenOnce(this.player, core.EventType.CHANGE_SOURCE_ENDED, () => {
const colorHexAsFilter = hexToCSSFilter(color, {acceptanceLossPercentage: 1}).filter;
const colorHexAsRGB = this.getColorAsRGB(color);

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.player.ui._uiManager.setCSSVariable(CONTROLS_FILTER_COLOR_VARIABLE, colorHexAsFilter.replace(';', ''));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.player.ui._uiManager.setCSSVariable(TONE_1_COLOR_RGB_VARIABLE, colorHexAsRGB);

if (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.player.ui._uiManager.getCSSVariable(CONTROLS_FILTER_COLOR_VARIABLE) &&
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.player.ui._uiManager.getCSSVariable(TONE_1_COLOR_RGB_VARIABLE)
this.player.ui._uiManager.getCSSVariable(CONTROLS_FILTER_COLOR_VARIABLE)
) {
this.colorVariablesSet = true;
}
Expand Down
Loading