Skip to content

Commit 98e0fdf

Browse files
committed
[css-navigation-1] Add partial work-in-progress draft of spec for CSS side.
(This is part of importing the history from WICG/declarative-partial-updates.)
1 parent df73361 commit 98e0fdf

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

css-navigation-1/Overview.bs

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<pre class="metadata">
2+
Title: CSS Route Matching
3+
Status: UD
4+
Work Status: Exploring
5+
Shortname: css-route-matching
6+
Org: w3c
7+
Level: 1
8+
Repository: WICG/declarative-route-matching
9+
!Issue Tracking: <a href="https://github.com/w3c/csswg-drafts/issues/12594">w3c/csswg-drafts#12594</a>
10+
ED: https://wicg.github.io/declarative-partial-updates/css-route-matching.html
11+
Editor: L. David Baron, Google https://www.google.com/, https://dbaron.org/, w3cid 15393
12+
Editor: Noam Rosenthal, Google https://www.google.com/, w3cid 121539
13+
Abstract: This module contains conditional CSS rules for styling based on routes
14+
declared in HTML. This allows styles to be conditioned on the current URL
15+
or conditioned on the status of navigating between particular URLs.
16+
</pre>
17+
<!-- for now using Org: w3c rather than Group: csswg because the latter forces an incorrect issue tracking link, overriding Repository -->
18+
19+
<h2 id="at-route">Route queries: the ''@route'' rule</h2>
20+
21+
The <dfn at-rule id="at-ruledef-route">@route</dfn> rule
22+
is a conditional group rule
23+
whose condition tests
24+
characteristics of the current URL
25+
or of the state of navigation between two URLs.
26+
These queries are called <dfn export>route queries</dfn>.
27+
28+
Authors can use it to:
29+
* write style sheets that apply to multiple pages
30+
but behave somewhat differently between those pages,
31+
* write style sheets that apply to
32+
single page applications
33+
that change their URL over time,
34+
so that style changes when the URL changes, and
35+
* write style sheets that declaratively start view transitions
36+
(or make other appropriate style changes)
37+
in response to navigations.
38+
39+
The syntax of the condition in the ''@route'' rule
40+
is similar to that defined for
41+
<<supports-condition>> in [[CSS-CONDITIONAL-3]].
42+
Negation, conjunction, and disjunction are all needed
43+
so that authors can specify the interaction of multiple styles
44+
in ways that are most intuitive and require the simplest code.
45+
46+
The syntax of the ''@route'' rule is:
47+
48+
<pre class="prod def" nohighlight>
49+
@route <<route-condition>> {
50+
<<rule-list>>
51+
}
52+
</pre>
53+
54+
with <<route-condition>> defined as:
55+
56+
<pre class="prod def" dfn-type="type" nohighlight>
57+
<dfn><<route-condition>></dfn> = not <<route-in-parens>>
58+
| <<route-in-parens>> [ and <<route-in-parens>> ]*
59+
| <<route-in-parens>> [ or <<route-in-parens>> ]*
60+
<dfn><<route-in-parens>></dfn> = ( <<route-condition>> ) | ( <<route-test>> ) | <<general-enclosed>>
61+
<dfn><<route-test>></dfn> = <<route-name>> | <<route-keyword>> : <<route-name>>
62+
<dfn><<route-keyword>></dfn> = at | to | from
63+
<!-- TODO(dbaron): Should this be <<ident>> or <<custom-ident>> ? -->
64+
<dfn><<route-name>></dfn> = <<custom-ident>>
65+
</pre>
66+
67+
The above grammar is purposely very loose for forwards-compatibility reasons,
68+
since the <<general-enclosed>> production
69+
allows for substantial future extensibility.
70+
Any ''@route'' rule that does not parse according to the grammar above
71+
(that is, a rule that does not match this loose grammar
72+
which includes the <<general-enclosed>> production)
73+
is invalid.
74+
Style sheets <strong>must not</strong> use such a rule and
75+
processors <strong>must</strong> ignore such a rule (including all of its contents).
76+
77+
A <<route-name>> is a reference to a route
78+
named in a <code highlight=html>&lt;script type=routemap></code>
79+
in the document.
80+
<span class="issue">This should be defined more formally once routemaps are.</span>
81+
82+
Many of these grammar terms are associated with a boolean result,
83+
as follows:
84+
85+
: <<route-condition>>
86+
:: : not <<route-in-parens>>
87+
:: The result is the negation of the <<route-in-parens>> term.
88+
89+
: <<route-in-parens>> [ and <<route-in-parens>> ]*
90+
::
91+
The result is true if all of the <<route-in-parens>> child terms are true,
92+
and false otherwise.
93+
94+
: <<route-in-parens>> [ or <<route-in-parens>> ]*
95+
::
96+
The result is false if all of the <<route-in-parens>> child terms are false,
97+
and true otherwise.
98+
99+
: <<route-in-parens>>
100+
:: The result is the result of the child subexpression.
101+
102+
: <<route-test>>
103+
:: : <<route-name>>
104+
: at: <<route-name>>
105+
:: The result is true if
106+
the document's [=Document/URL=] [=URL pattern/match|matches=]
107+
the URL pattern of a route named <<route-name>>
108+
declared in a <code highlight=html>&lt;script type=routemap></code>.
109+
110+
: to: <<route-name>>
111+
:: The result is true if
112+
the document's [=node navigable=]'s
113+
@@@ @@@ <span class="issue">define this properly</span>
114+
[=URL pattern/match|matches=]
115+
the URL pattern of a route named <<route-name>>
116+
declared in a <code highlight=html>&lt;script type=routemap></code>.
117+
118+
: from: <<route-name>>
119+
:: The result is true if
120+
the document's [=node navigable=]'s
121+
@@@ @@@ <span class="issue">define this properly</span>
122+
[=URL pattern/match|matches=]
123+
the URL pattern of a route named <<route-name>>
124+
declared in a <code highlight=html>&lt;script type=routemap></code>.
125+
126+
ISSUE: Once routemaps are defined more formally,
127+
this should be defined in terms of the routemap definition
128+
instead of referring directly to URLPattern.
129+
130+
: <<general-enclosed>>
131+
::
132+
The result is false.
133+
134+
Authors must not use <<general-enclosed>> in their stylesheets.
135+
<span class='note'>It exists only for future-compatibility,
136+
so that new syntax additions do not invalidate too much of a <<route-condition>> in older user agents.</span>
137+
138+
The condition of the ''@route'' rule
139+
is the result of the <<route-condition>> in its prelude.
140+

0 commit comments

Comments
 (0)