diff options
| author | HJ <30-hj@users.noreply.git.pleroma.social> | 2020-03-07 14:33:19 +0000 |
|---|---|---|
| committer | HJ <30-hj@users.noreply.git.pleroma.social> | 2020-03-07 14:33:19 +0000 |
| commit | 2c3db2b6a2c755c4ca569f3031d6e3cbe507b116 (patch) | |
| tree | ec29a29d40b0b446192d297bcfa1f406d5db8bce /src | |
| parent | 147364b80cae7a0fac1ccf00b5669a20de1b7e67 (diff) | |
| parent | a485386a3b07f831859fcefa9cd429fc801fd8eb (diff) | |
Merge branch 'fix/themes-2.1-opacity-again' into 'develop'
fix several issues related to opacity
Closes #787 and #789
See merge request pleroma/pleroma-fe!1081
Diffstat (limited to 'src')
| -rw-r--r-- | src/services/theme_data/theme_data.service.js | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/services/theme_data/theme_data.service.js b/src/services/theme_data/theme_data.service.js index de6561cd..dd87e3cf 100644 --- a/src/services/theme_data/theme_data.service.js +++ b/src/services/theme_data/theme_data.service.js @@ -350,17 +350,47 @@ export const getColors = (sourceColors, sourceOpacity) => SLOT_ORDERED.reduce(({ if (!outputColor) { throw new Error('Couldn\'t generate color for ' + key) } - const opacitySlot = getOpacitySlot(key) + + const opacitySlot = value.opacity || getOpacitySlot(key) const ownOpacitySlot = value.opacity - const opacityOverriden = ownOpacitySlot && sourceOpacity[opacitySlot] !== undefined - if (opacitySlot && (outputColor.a === undefined || opacityOverriden)) { + + if (ownOpacitySlot === null) { + outputColor.a = 1 + } else if (sourceColor === 'transparent') { + outputColor.a = 0 + } else { + const opacityOverriden = ownOpacitySlot && sourceOpacity[opacitySlot] !== undefined + const dependencySlot = deps[0] - if (dependencySlot && colors[dependencySlot] === 'transparent') { - outputColor.a = 0 + const dependencyColor = dependencySlot && colors[dependencySlot] + + if (!ownOpacitySlot && dependencyColor && !value.textColor && ownOpacitySlot !== null) { + // Inheriting color from dependency (weird, i know) + // except if it's a text color or opacity slot is set to 'null' + outputColor.a = dependencyColor.a + } else if (!dependencyColor && !opacitySlot) { + // Remove any alpha channel if no dependency and no opacitySlot found + delete outputColor.a } else { - outputColor.a = Number(sourceOpacity[opacitySlot]) || OPACITIES[opacitySlot].defaultValue || 1 + // Otherwise try to assign opacity + if (dependencyColor && dependencyColor.a === 0) { + // transparent dependency shall make dependents transparent too + outputColor.a = 0 + } else { + // Otherwise check if opacity is overriden and use that or default value instead + outputColor.a = Number( + opacityOverriden + ? sourceOpacity[opacitySlot] + : (OPACITIES[opacitySlot] || {}).defaultValue + ) + } } } + + if (Number.isNaN(outputColor.a) || outputColor.a === undefined) { + outputColor.a = 1 + } + if (opacitySlot) { return { colors: { ...colors, [key]: outputColor }, |
