Skip to content

Commit 1c92824

Browse files
authored
Clarify API doc + switch to empty string for removing User Settings flags
2 parents feef2c0 + 8a61280 commit 1c92824

6 files changed

Lines changed: 122 additions & 73 deletions

File tree

docs/CSS12-user_prefs.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,30 @@ You don’t need to remove the variable before setting another value, the new va
3737

3838
#### Removing
3939

40+
You can either remove the style explicitly with `removeProperty()`:
41+
4042
```
4143
var root = document.documentElement;
4244
4345
root.style.removeProperty("name of var");
4446
```
4547

48+
Or implicitly by using an empty string as a value with `setProperty()`:
49+
50+
```
51+
var root = document.documentElement;
52+
53+
root.style.setProperty("name of var", "");
54+
```
55+
56+
Setting a property with an empty string as the value will indeed invoke `removeProperty()`, as defined in the [CSS Object Model Spec](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty).
57+
4658
## Flags
4759

4860
Some variables behave like flags. You could also use custom `data-*` attributes or CSS classes to manage the following ones. See the [“Quickstart” doc](../docs/CSS02-quickstart.md) for customization.
4961

62+
By default, those flags are not set. Then their initialization depends on your user settings’ management e.g. apply user settings to all EPUBs, only the ones that have already been customized, etc.
63+
5064
### User view
5165

5266
Allows to switch between paged and scroll view.
@@ -55,10 +69,12 @@ Allows to switch between paged and scroll view.
5569
--USER__view
5670
```
5771

58-
Possible values: `readium-paged-on` | `readium-scroll-on`
72+
Supported values: `readium-paged-on` | `readium-scroll-on`
5973

6074
Override class: Chrome (should be applied by any means necessary)
6175

76+
If the flag is not set, ReadiumCSS will fall back to the paged view.
77+
6278
### Font Family override
6379

6480
Acts as an explicit switch to override the publisher’s `font-family`.
@@ -67,11 +83,11 @@ Acts as an explicit switch to override the publisher’s `font-family`.
6783
--USER__fontOverride
6884
```
6985

70-
Possible values: `readium-font-on` | `readium-font-off`
86+
Supported value: `readium-font-on`
7187

7288
Override class: None. This flag is required to change the `font-family` user setting.
7389

74-
To switch back to the publisher’s font, you can either change the value to `readium-font-off` or remove the flag.
90+
To switch back to the publisher’s font, you can either set an empty string as a value or remove the property.
7591

7692
### Advanced Settings
7793

@@ -83,11 +99,11 @@ If you provide users with a “Publisher’s styles” toggle, it must be enable
8399
--USER__advancedSettings
84100
```
85101

86-
Possible values: `readium-advanced-on` | `readium-advanced-off`
102+
Supported value: `readium-advanced-on`
87103

88104
Override class: None. This flag is required to apply the `font-family`, the `font-size` and/or advanced user settings.
89105

90-
To switch back to the publisher’s styles, you can either change the value to `readium-advanced-off` or remove it. This will disable all advanced settings requiring the flag.
106+
To switch back to the publisher’s styles, you can either set an empty string as a value or remove the property. This will disable all advanced settings requiring the flag.
91107

92108
### Reading Modes
93109

@@ -97,10 +113,12 @@ We currently have two reading modes for night and sepia.
97113
--USER__appearance
98114
```
99115

100-
Possible values: `readium-day-on` | `readium-sepia-on` | `readium-night-on`
116+
Supported values: `readium-day-on` | `readium-sepia-on` | `readium-night-on`
101117

102118
Override class: Chrome (should be applied by any means necessary)
103119

120+
If the flag is not set, ReadiumCSS will fall back to the day mode.
121+
104122
### Filters
105123

106124
Please note night mode provides two extra specific variables:
@@ -109,18 +127,22 @@ Please note night mode provides two extra specific variables:
109127
--USER__darkenFilter
110128
```
111129

112-
Possible values: `readium-darken-on` | `readium-darken-off`
130+
Supported value: `readium-darken-on`
113131

114132
Override class: Chrome advanced (optional but should be applied by any means necessary if provided to users)
115133

134+
To disable the filter, you can either set an empty string as a value or remove the property.
135+
116136
```
117137
--USER__invertFilter
118138
```
119139

120-
Possible values: `readium-invert-on` | `readium-invert-off`
140+
Supported value: `readium-invert-on`
121141

122142
Override class: Chrome advanced (optional but should be applied by any means necessary if provided to users)
123143

144+
To disable the filter, you can either set an empty string as a value or remove the property.
145+
124146
### Accessibility Normalization
125147

126148
Users may want to normalize text (no bold, no italics, etc.) for accessibility reasons, using a non a11y-specific typeface.
@@ -129,12 +151,14 @@ Users may want to normalize text (no bold, no italics, etc.) for accessibility r
129151
--USER__a11yNormalize
130152
```
131153

132-
Possible values: `readium-a11y-on` | `readium-a11y-off`
154+
Supported value: `readium-a11y-on`
133155

134156
Required flag: `--USER__fontOverride: readium-font-on`
135157

136158
Override class: User settings advanced (optional but should be applied by any means necessary if provided to users)
137159

160+
To disable the normalization, you can either set an empty string as a value or remove the property.
161+
138162
## List of variables
139163

140164
### Layout

docs/CSS19-api.md

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[Implementers’ doc]
44

5+
This document is meant to list all the customizable medias and flags (to be found in `ReadiumCSS-config.css`), as well as all the CSS variables for Reading System and User styles available in the `dist` stylesheets.
6+
57
As a reminder, the priority is, in general:
68

79
```
@@ -30,6 +32,8 @@ root.style.removeProperty("--USER__var");
3032

3133
## Customizable medias
3234

35+
You will find those customizable medias in `ReadiumCSS-config.css`. The values defined are used in media queries to control use of the auto pagination model.
36+
3337
* * *
3438

3539
```
@@ -66,21 +70,33 @@ The maximum device width of the mobile device for which the auto pagination mode
6670

6771
## Customizable flags
6872

69-
Those custom selectors can be customized before runtime. Check the [“Quickstart” doc](../docs/CSS02-quickstart.md) for further details.
73+
You will find those customizable flags in `ReadiumCSS-config.css`, and can think of the preset values as boolean inline styles: if they are set on the `:root` element (i.e. `html`) then the flag is enabled. If another value is, or they are removed, then the flag is disabled.
74+
75+
Those custom selectors can only be customized before runtime. You could for example use a class or a custom attribute instead of an inline style. Check the [“User Preferences”](../docs/CSS12-user_prefs.md#flags) and [“Quickstart”](../docs/CSS02-quickstart.md) docs for further details.
7076

71-
The “dummy CSS variable” is a recommended CSS custom property name you can use to set the default value if you don’t customize those selectors and just keep the default.
77+
**Note:** The preset is not a default implementers should use. Indeed, the initialization of those flags depends on your user settings’ management e.g. apply user settings to all EPUBs, only the ones that have already been customized, etc.
7278

7379
* * *
7480

7581
```
76-
:--scroll-view
82+
:--paged-view
7783
```
7884

79-
Default is `readium-scroll-on`
85+
Preset: `--USER__view: readium-paged-on`
8086

8187
Scope: `html`
8288

83-
Dummy CSS variable: `--USER__view`
89+
Override class: Chrome (should be applied by any means necessary)
90+
91+
* * *
92+
93+
```
94+
:--scroll-view
95+
```
96+
97+
Preset: `--USER__view: readium-scroll-on`
98+
99+
Scope: `html`
84100

85101
Override class: Chrome (should be applied by any means necessary)
86102

@@ -90,12 +106,10 @@ Override class: Chrome (should be applied by any means necessary)
90106
:--font-override
91107
```
92108

93-
Default is `readium-font-on`
109+
Preset: `--USER__fontOverride: readium-font-on`
94110

95111
Scope: `html`
96112

97-
Dummy CSS variable: `--USER__fontOverride`
98-
99113
Override class: None. This flag is required to change the `font-family` user setting.
100114

101115
* * *
@@ -104,12 +118,10 @@ Override class: None. This flag is required to change the `font-family` user set
104118
:--advanced-settings
105119
```
106120

107-
Default is `readium-advanced-on`
121+
Preset: `--USER__advancedSettings: readium-advanced-on`
108122

109123
Scope: `html`
110124

111-
Dummy CSS variable: `--USER__advancedSettings`
112-
113125
Override class: None. This flag is required to apply the `font-family`, the `font-size` and/or advanced user settings.
114126

115127
* * *
@@ -118,12 +130,10 @@ Override class: None. This flag is required to apply the `font-family`, the `fon
118130
:--sepia-mode
119131
```
120132

121-
Default is `readium-sepia-on`
133+
Preset: `--USER__appearance: readium-sepia-on`
122134

123135
Scope: `html`
124136

125-
Dummy CSS variable: `--USER__appearance`
126-
127137
Override class: Chrome (should be applied by any means necessary)
128138

129139
This flag applies the sepia reading mode.
@@ -134,12 +144,10 @@ This flag applies the sepia reading mode.
134144
:--night-mode
135145
```
136146

137-
Default is `readium-night-on`
147+
Preset: `--USER__appearance: readium-night-on`
138148

139149
Scope: `html`
140150

141-
Dummy CSS variable: `--USER__appearance`
142-
143151
Override class: Chrome (should be applied by any means necessary)
144152

145153
This flag applies the night reading mode.
@@ -150,12 +158,10 @@ This flag applies the night reading mode.
150158
:--darken-filter
151159
```
152160

153-
Default is `readium-darken-on`
161+
Preset: `--USER__darkenImages: readium-darken-on`
154162

155163
Scope: `html`
156164

157-
Dummy CSS variable: `--USER__darkenImages`
158-
159165
Override class: Chrome advanced (optional but should be applied by any means necessary if provided to users)
160166

161167
This will only apply in night mode to darken images and impact `img`.
@@ -166,12 +172,10 @@ This will only apply in night mode to darken images and impact `img`.
166172
:--invert-filter
167173
```
168174

169-
Default is `readium-invert-on`
175+
Preset: `--USER__invertImages: readium-invert-on`
170176

171177
Scope: `html`
172178

173-
Dummy CSS variable: `--USER__invertImages`
174-
175179
Override class: Chrome advanced (optional but should be applied by any means necessary if provided to users)
176180

177181
This will only apply in night mode to invert images and impact `img`.
@@ -182,12 +186,10 @@ This will only apply in night mode to invert images and impact `img`.
182186
:--a11y-normalize
183187
```
184188

185-
Default is `readium-a11y-on`
189+
Preset: `--USER__a11yNormalize: readium-a11y-on`
186190

187191
Scope: `html`
188192

189-
Dummy CSS variable: `--USER__a11yNormalize`
190-
191193
Required flag: `:--fontOverride`
192194

193195
Override class: User settings advanced (optional but should be applied by any means necessary if provided to users)

docs/ReadiumCSS_docs.epub

-374 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)