Skip to content

Commit

Permalink
Update: remove text-shadow + box-shadow when 'No Transparency' enabled (
Browse files Browse the repository at this point in the history
fixes #73) (#113)

* remove 'text-shadow' when 'no transparency' enabled

* for 'no transparency', only remove box-shadow with transparency

* README 'no transparency' note added
  • Loading branch information
kirsty-hames authored Apr 16, 2024
1 parent 98bbb4f commit 2553ec4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ It provides visual accessibility improvements.
* In order to support paragraph spacing, all body text needs to be wrapped in [paragraph tags](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p).
* Font size medium is the default font size (16px usually), large is 18pt, small is 9pt.
* Hide decorative images is contingent on alt text.
* No transparency removes `box-shadow` (where transparency is used), `text-shadow` and `opacity` styles.

### Theme considerations
* All colour transformations are applied by mathematical shifts. It is therefore important that the course start from AA colour contrast for the algorithms to be applicable.
Expand Down
15 changes: 13 additions & 2 deletions js/CSSRuleModifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,25 @@ import Color from './Color';
*/
export default [
[
// Remove box shadows
'box-shadow',
// Remove text shadows
'text-shadow',
null,
function () {
if (!this.noTransparency) return;
return 'none';
}
],
[
// Remove box shadows with transparency
'box-shadow',
null,
function (output) {
if (!this.noTransparency) return;
const zeroOffsetAndBlur = '0px 0px 0px';
if (output.includes(zeroOffsetAndBlur)) return;
return 'none';
}
],
[
// Increase opacity either way
'opacity',
Expand Down

0 comments on commit 2553ec4

Please sign in to comment.