New full screen chat WIP + code refactoring.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import type { SVGButton } from './buttons'
|
||||
import { logger } from './logger'
|
||||
import { logger } from '../utils/logger'
|
||||
|
||||
interface displayButtonOptionsBase {
|
||||
buttonContainer: HTMLElement
|
||||
|
@ -1,46 +0,0 @@
|
||||
import { logger } from './logger'
|
||||
import { AutoColors, areAutoColorsValid } from 'shared/lib/autocolors'
|
||||
|
||||
function computeAutoColors (): AutoColors | null {
|
||||
if (!window.getComputedStyle) {
|
||||
logger.warn('[AutoColors] getComputedStyle is not available, aborting.')
|
||||
return null
|
||||
}
|
||||
|
||||
const styles = window.getComputedStyle(document.body)
|
||||
|
||||
// Peertube has no CSS variable for the button color...
|
||||
// Computing by hand.
|
||||
// Searching for one of these button:
|
||||
const button = document.querySelector('.publish-button') ?? document.querySelector('.peertube-button-link')
|
||||
if (!button) {
|
||||
logger.warn('[AutoColors] Cant find a button, aborting.')
|
||||
return null
|
||||
}
|
||||
const buttonStyles = window.getComputedStyle(button)
|
||||
|
||||
const autocolors: AutoColors = {
|
||||
mainForeground: styles.getPropertyValue('--mainForegroundColor').trim(),
|
||||
mainBackground: styles.getPropertyValue('--mainBackgroundColor').trim(),
|
||||
greyForeground: styles.getPropertyValue('--greyForegroundColor').trim(),
|
||||
greyBackground: styles.getPropertyValue('--greyBackgroundColor').trim(),
|
||||
menuForeground: styles.getPropertyValue('--menuForegroundColor').trim(),
|
||||
menuBackground: styles.getPropertyValue('--menuBackgroundColor').trim(),
|
||||
inputForeground: styles.getPropertyValue('--inputForegroundColor').trim(),
|
||||
inputBackground: styles.getPropertyValue('--inputBackgroundColor').trim(),
|
||||
buttonForeground: buttonStyles.color.trim(),
|
||||
buttonBackground: styles.getPropertyValue('--mainColor').trim(),
|
||||
link: styles.getPropertyValue('--mainForegroundColor').trim(),
|
||||
linkHover: styles.getPropertyValue('--mainForegroundColor').trim()
|
||||
}
|
||||
const autoColorsTest = areAutoColorsValid(autocolors)
|
||||
if (autoColorsTest !== true) {
|
||||
logger.warn('[AutoColors] Computed colors are not valid, dropping. Invalid values: ' + autoColorsTest.join(', '))
|
||||
return null
|
||||
}
|
||||
return autocolors
|
||||
}
|
||||
|
||||
export {
|
||||
computeAutoColors
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
const logger = {
|
||||
log: (s: string) => console.log('[peertube-plugin-livechat] ' + s),
|
||||
info: (s: string) => console.info('[peertube-plugin-livechat] ' + s),
|
||||
error: (s: string) => console.error('[peertube-plugin-livechat] ' + s),
|
||||
warn: (s: string) => console.warn('[peertube-plugin-livechat] ' + s)
|
||||
}
|
||||
|
||||
export {
|
||||
logger
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||
import type { Video } from '@peertube/peertube-types'
|
||||
import { helpButtonSVG } from './buttons'
|
||||
import { logger } from './logger'
|
||||
import { logger } from '../utils/logger'
|
||||
import { getIframeUri, getXMPPAddr, UriOptions } from './uri'
|
||||
import { isAutoColorsAvailable } from 'shared/lib/autocolors'
|
||||
import { localizedHelpUrl } from '../utils/help'
|
||||
|
@ -2,8 +2,8 @@ import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||
import type { Video } from '@peertube/peertube-types'
|
||||
import { AutoColors, isAutoColorsAvailable } from 'shared/lib/autocolors'
|
||||
import { getBaseRoute } from '../utils/uri'
|
||||
import { logger } from './logger'
|
||||
import { computeAutoColors } from './colors'
|
||||
import { logger } from '../utils/logger'
|
||||
import { computeAutoColors } from '../utils/colors'
|
||||
|
||||
interface UriOptions {
|
||||
readonly?: boolean | 'noscroll'
|
||||
|
Reference in New Issue
Block a user