@canonical/prism 0.0.0-stage → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +166 -0
- package/README.md +355 -2
- package/dist/esm/index.js +22 -0
- package/dist/esm/lib/Card/Card.js +16 -0
- package/dist/esm/lib/Card/CardView.js +19 -0
- package/dist/esm/lib/Card/index.js +2 -0
- package/dist/esm/lib/Card/styles.css +68 -0
- package/dist/esm/lib/Card/types.js +1 -0
- package/dist/esm/lib/Chip/Chip.js +16 -0
- package/dist/esm/lib/Chip/ChipView.js +14 -0
- package/dist/esm/lib/Chip/index.js +2 -0
- package/dist/esm/lib/Chip/styles.css +11 -0
- package/dist/esm/lib/Chip/types.js +1 -0
- package/dist/esm/lib/CommandPalette/CommandPalette.js +166 -0
- package/dist/esm/lib/CommandPalette/ThingOptions.js +38 -0
- package/dist/esm/lib/CommandPalette/index.js +1 -0
- package/dist/esm/lib/CommandPalette/styles.css +91 -0
- package/dist/esm/lib/CommandPalette/types.js +1 -0
- package/dist/esm/lib/Fact/FactValue.js +12 -0
- package/dist/esm/lib/Fact/index.js +1 -0
- package/dist/esm/lib/Fact/types.js +1 -0
- package/dist/esm/lib/Navigation/Navigation.js +46 -0
- package/dist/esm/lib/Navigation/index.js +1 -0
- package/dist/esm/lib/Navigation/styles.css +44 -0
- package/dist/esm/lib/Navigation/types.js +1 -0
- package/dist/esm/lib/PageHeader/PageHeader.js +16 -0
- package/dist/esm/lib/PageHeader/PageHeaderView.js +18 -0
- package/dist/esm/lib/PageHeader/index.js +2 -0
- package/dist/esm/lib/PageHeader/readParents.js +19 -0
- package/dist/esm/lib/PageHeader/styles.css +67 -0
- package/dist/esm/lib/PageHeader/types.js +1 -0
- package/dist/esm/lib/Prism/Prism.js +14 -0
- package/dist/esm/lib/Prism/context.js +10 -0
- package/dist/esm/lib/Prism/index.js +2 -0
- package/dist/esm/lib/Prism/types.js +1 -0
- package/dist/esm/lib/Prose/Prose.js +26 -0
- package/dist/esm/lib/Prose/findMention.js +22 -0
- package/dist/esm/lib/Prose/index.js +2 -0
- package/dist/esm/lib/Prose/styles.css +10 -0
- package/dist/esm/lib/Prose/types.js +1 -0
- package/dist/esm/lib/Row/Row.js +16 -0
- package/dist/esm/lib/Row/RowView.js +18 -0
- package/dist/esm/lib/Row/index.js +2 -0
- package/dist/esm/lib/Row/styles.css +28 -0
- package/dist/esm/lib/Row/types.js +1 -0
- package/dist/esm/lib/SearchBoundary/SearchBoundary.js +37 -0
- package/dist/esm/lib/SearchBoundary/index.js +1 -0
- package/dist/esm/lib/SearchBoundary/types.js +1 -0
- package/dist/esm/lib/SearchPage/SearchPage.js +35 -0
- package/dist/esm/lib/SearchPage/index.js +1 -0
- package/dist/esm/lib/SearchPage/styles.css +62 -0
- package/dist/esm/lib/SearchPage/types.js +1 -0
- package/dist/esm/lib/SiteLayout/SiteLayout.js +20 -0
- package/dist/esm/lib/SiteLayout/index.js +1 -0
- package/dist/esm/lib/SiteLayout/styles.css +112 -0
- package/dist/esm/lib/SiteLayout/types.js +1 -0
- package/dist/esm/lib/ThingLink/ThingLink.js +10 -0
- package/dist/esm/lib/ThingLink/index.js +1 -0
- package/dist/esm/lib/ThingLink/types.js +1 -0
- package/dist/esm/lib/ThingResults/ThingList.js +11 -0
- package/dist/esm/lib/ThingResults/ThingResults.js +36 -0
- package/dist/esm/lib/ThingResults/index.js +1 -0
- package/dist/esm/lib/ThingResults/types.js +1 -0
- package/dist/esm/lib/graphql/PrismCard.js +35 -0
- package/dist/esm/lib/graphql/PrismChip.js +17 -0
- package/dist/esm/lib/graphql/PrismClasses.js +33 -0
- package/dist/esm/lib/graphql/PrismFact.js +17 -0
- package/dist/esm/lib/graphql/PrismPageHeader.js +59 -0
- package/dist/esm/lib/graphql/PrismRow.js +32 -0
- package/dist/esm/lib/graphql/__generated__/PrismCard_node.graphql.js +136 -0
- package/dist/esm/lib/graphql/__generated__/PrismChip_node.graphql.js +64 -0
- package/dist/esm/lib/graphql/__generated__/PrismClasses_node.graphql.js +92 -0
- package/dist/esm/lib/graphql/__generated__/PrismFact_fact.graphql.js +46 -0
- package/dist/esm/lib/graphql/__generated__/PrismPageHeader_node.graphql.js +237 -0
- package/dist/esm/lib/graphql/__generated__/PrismRow_node.graphql.js +127 -0
- package/dist/esm/lib/graphql/index.js +6 -0
- package/dist/esm/lib/lens/constants.js +2 -0
- package/dist/esm/lib/lens/index.js +3 -0
- package/dist/esm/lib/lens/isShortcutKey.js +22 -0
- package/dist/esm/lib/lens/readLenses.js +106 -0
- package/dist/esm/lib/lens/types.js +1 -0
- package/dist/esm/lib/projection/findNearest.js +12 -0
- package/dist/esm/lib/projection/index.js +5 -0
- package/dist/esm/lib/projection/orderClasses.js +14 -0
- package/dist/esm/lib/projection/readHomes.js +43 -0
- package/dist/esm/lib/projection/types.js +1 -0
- package/dist/esm/lib/projection/useProjection.js +34 -0
- package/dist/esm/lib/projection/withLabel.js +9 -0
- package/dist/esm/lib/renderPage/index.js +1 -0
- package/dist/esm/lib/renderPage/renderPage.js +125 -0
- package/dist/esm/lib/renderPage/types.js +1 -0
- package/dist/esm/lib/search/filterLenses.js +11 -0
- package/dist/esm/lib/search/index.js +3 -0
- package/dist/esm/lib/search/searchVariables.js +11 -0
- package/dist/esm/lib/search/warmSearch.js +14 -0
- package/dist/esm/lib/searchQuery/PrismSearchQuery.js +23 -0
- package/dist/esm/lib/searchQuery/__generated__/PrismSearchQuery.graphql.js +304 -0
- package/dist/esm/lib/searchQuery/index.js +1 -0
- package/dist/esm/lib/warmQuery/index.js +1 -0
- package/dist/esm/lib/warmQuery/warmQuery.js +43 -0
- package/dist/esm/server.js +6 -0
- package/dist/types/index.d.ts +24 -0
- package/dist/types/lib/Card/Card.d.ts +8 -0
- package/dist/types/lib/Card/CardView.d.ts +11 -0
- package/dist/types/lib/Card/index.d.ts +3 -0
- package/dist/types/lib/Card/types.d.ts +31 -0
- package/dist/types/lib/Chip/Chip.d.ts +8 -0
- package/dist/types/lib/Chip/ChipView.d.ts +9 -0
- package/dist/types/lib/Chip/index.d.ts +3 -0
- package/dist/types/lib/Chip/types.d.ts +24 -0
- package/dist/types/lib/CommandPalette/CommandPalette.d.ts +16 -0
- package/dist/types/lib/CommandPalette/ThingOptions.d.ts +7 -0
- package/dist/types/lib/CommandPalette/index.d.ts +2 -0
- package/dist/types/lib/CommandPalette/types.d.ts +45 -0
- package/dist/types/lib/Fact/FactValue.d.ts +7 -0
- package/dist/types/lib/Fact/index.d.ts +2 -0
- package/dist/types/lib/Fact/types.d.ts +5 -0
- package/dist/types/lib/Navigation/Navigation.d.ts +15 -0
- package/dist/types/lib/Navigation/index.d.ts +2 -0
- package/dist/types/lib/Navigation/types.d.ts +6 -0
- package/dist/types/lib/PageHeader/PageHeader.d.ts +8 -0
- package/dist/types/lib/PageHeader/PageHeaderView.d.ts +10 -0
- package/dist/types/lib/PageHeader/index.d.ts +3 -0
- package/dist/types/lib/PageHeader/readParents.d.ts +13 -0
- package/dist/types/lib/PageHeader/types.d.ts +32 -0
- package/dist/types/lib/Prism/Prism.d.ts +8 -0
- package/dist/types/lib/Prism/context.d.ts +7 -0
- package/dist/types/lib/Prism/index.d.ts +3 -0
- package/dist/types/lib/Prism/types.d.ts +67 -0
- package/dist/types/lib/Prose/Prose.d.ts +11 -0
- package/dist/types/lib/Prose/findMention.d.ts +8 -0
- package/dist/types/lib/Prose/index.d.ts +3 -0
- package/dist/types/lib/Prose/types.d.ts +7 -0
- package/dist/types/lib/Row/Row.d.ts +8 -0
- package/dist/types/lib/Row/RowView.d.ts +12 -0
- package/dist/types/lib/Row/index.d.ts +3 -0
- package/dist/types/lib/Row/types.d.ts +25 -0
- package/dist/types/lib/SearchBoundary/SearchBoundary.d.ts +17 -0
- package/dist/types/lib/SearchBoundary/index.d.ts +2 -0
- package/dist/types/lib/SearchBoundary/types.d.ts +22 -0
- package/dist/types/lib/SearchPage/SearchPage.d.ts +15 -0
- package/dist/types/lib/SearchPage/index.d.ts +2 -0
- package/dist/types/lib/SearchPage/types.d.ts +10 -0
- package/dist/types/lib/SiteLayout/SiteLayout.d.ts +17 -0
- package/dist/types/lib/SiteLayout/index.d.ts +2 -0
- package/dist/types/lib/SiteLayout/types.d.ts +11 -0
- package/dist/types/lib/ThingLink/ThingLink.d.ts +8 -0
- package/dist/types/lib/ThingLink/index.d.ts +2 -0
- package/dist/types/lib/ThingLink/types.d.ts +9 -0
- package/dist/types/lib/ThingResults/ThingList.d.ts +4 -0
- package/dist/types/lib/ThingResults/ThingResults.d.ts +16 -0
- package/dist/types/lib/ThingResults/index.d.ts +2 -0
- package/dist/types/lib/ThingResults/types.d.ts +14 -0
- package/dist/types/lib/graphql/PrismCard.d.ts +6 -0
- package/dist/types/lib/graphql/PrismChip.d.ts +3 -0
- package/dist/types/lib/graphql/PrismClasses.d.ts +8 -0
- package/dist/types/lib/graphql/PrismFact.d.ts +6 -0
- package/dist/types/lib/graphql/PrismPageHeader.d.ts +8 -0
- package/dist/types/lib/graphql/PrismRow.d.ts +6 -0
- package/dist/types/lib/graphql/__generated__/PrismCard_node.graphql.d.ts +38 -0
- package/dist/types/lib/graphql/__generated__/PrismChip_node.graphql.d.ts +23 -0
- package/dist/types/lib/graphql/__generated__/PrismClasses_node.graphql.d.ts +33 -0
- package/dist/types/lib/graphql/__generated__/PrismFact_fact.graphql.d.ts +20 -0
- package/dist/types/lib/graphql/__generated__/PrismPageHeader_node.graphql.d.ts +60 -0
- package/dist/types/lib/graphql/__generated__/PrismRow_node.graphql.d.ts +35 -0
- package/dist/types/lib/graphql/index.d.ts +6 -0
- package/dist/types/lib/lens/constants.d.ts +2 -0
- package/dist/types/lib/lens/index.d.ts +4 -0
- package/dist/types/lib/lens/isShortcutKey.d.ts +6 -0
- package/dist/types/lib/lens/readLenses.d.ts +27 -0
- package/dist/types/lib/lens/types.d.ts +48 -0
- package/dist/types/lib/projection/findNearest.d.ts +6 -0
- package/dist/types/lib/projection/index.d.ts +6 -0
- package/dist/types/lib/projection/orderClasses.d.ts +19 -0
- package/dist/types/lib/projection/readHomes.d.ts +11 -0
- package/dist/types/lib/projection/types.d.ts +15 -0
- package/dist/types/lib/projection/useProjection.d.ts +9 -0
- package/dist/types/lib/projection/withLabel.d.ts +8 -0
- package/dist/types/lib/renderPage/index.d.ts +2 -0
- package/dist/types/lib/renderPage/renderPage.d.ts +21 -0
- package/dist/types/lib/renderPage/types.d.ts +49 -0
- package/dist/types/lib/search/filterLenses.d.ts +6 -0
- package/dist/types/lib/search/index.d.ts +3 -0
- package/dist/types/lib/search/searchVariables.d.ts +9 -0
- package/dist/types/lib/search/warmSearch.d.ts +9 -0
- package/dist/types/lib/searchQuery/PrismSearchQuery.d.ts +8 -0
- package/dist/types/lib/searchQuery/__generated__/PrismSearchQuery.graphql.d.ts +26 -0
- package/dist/types/lib/searchQuery/index.d.ts +1 -0
- package/dist/types/lib/warmQuery/index.d.ts +1 -0
- package/dist/types/lib/warmQuery/warmQuery.d.ts +19 -0
- package/dist/types/server.d.ts +6 -0
- package/package.json +108 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
166
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,356 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @canonical/prism
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The site engine of Prism: the navigation, the layout, the command palette, the
|
|
4
|
+
search page and the server render of a site that documents a knowledge graph,
|
|
5
|
+
and the four projections that draw any thing of that graph. It reads the
|
|
6
|
+
site's own route table; it creates no route table and no Relay environment of
|
|
7
|
+
its own, a provider only when the site replaces a projection or its text,
|
|
8
|
+
and it does not know Relay's store.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
bun add @canonical/prism
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
React, React DOM, `react-relay`, `relay-runtime`, `@canonical/router-core`,
|
|
17
|
+
`@canonical/router-react` and `@canonical/react-hooks` are peer dependencies:
|
|
18
|
+
the site and the engine must share one copy of each, or the router's and the
|
|
19
|
+
preferences' contexts split.
|
|
20
|
+
|
|
21
|
+
## Styles
|
|
22
|
+
|
|
23
|
+
Each component imports its own stylesheet from its module; a site's bundler
|
|
24
|
+
puts it in the site's stylesheet, which the server's page links. There is no
|
|
25
|
+
separate sheet to link.
|
|
26
|
+
|
|
27
|
+
Every rule sits in the `lib` cascade layer, which `@canonical/styles` declares
|
|
28
|
+
for a library outside the design system: above every design-system layer and
|
|
29
|
+
below `app`, so a site overrides the engine from its own `@layer app`.
|
|
30
|
+
|
|
31
|
+
## A lens is its routes
|
|
32
|
+
|
|
33
|
+
A lens is a section of the site with an entry in the navigation. It is a set
|
|
34
|
+
of ordinary router routes: its list route carries `meta.lens` (label, place,
|
|
35
|
+
icon, shortcut), and every other route of the lens names the list route in
|
|
36
|
+
`meta.lensOf`, so the navigation marks the lens on those pages too. The
|
|
37
|
+
navigation, the palette and the search page all read the lenses from the
|
|
38
|
+
route table; there is no list to keep beside it.
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import type { PrismRouteMeta } from "@canonical/prism";
|
|
42
|
+
import { warmQuery } from "@canonical/prism";
|
|
43
|
+
import { route } from "@canonical/router-core";
|
|
44
|
+
|
|
45
|
+
const componentsRoutes = {
|
|
46
|
+
components: route({
|
|
47
|
+
url: "/components",
|
|
48
|
+
content: ComponentsPage,
|
|
49
|
+
warm: (_params, _search, { context, signal }) =>
|
|
50
|
+
warmQuery(context.environment, componentsQuery, {}, { signal }),
|
|
51
|
+
meta: {
|
|
52
|
+
lens: { label: "Components", order: 2, icon: <ComponentsIcon />, shortcut: "2" },
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
component: route({
|
|
56
|
+
url: "/components/:uri",
|
|
57
|
+
content: ComponentPage,
|
|
58
|
+
meta: { lensOf: "components" },
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
declare module "@canonical/router-react" {
|
|
63
|
+
interface RouterRegister {
|
|
64
|
+
routes: typeof routes;
|
|
65
|
+
meta: PrismRouteMeta;
|
|
66
|
+
context: { readonly environment: Environment };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The route table is checked on the first render and the first request: a
|
|
72
|
+
malformed `meta.lens`, a lens whose list route takes parameters, two lenses in
|
|
73
|
+
one place or on one key, a lens on the palette's `/`, or a `lensOf` that names
|
|
74
|
+
no lens is an error.
|
|
75
|
+
|
|
76
|
+
## The frame
|
|
77
|
+
|
|
78
|
+
`SiteLayout` puts the navigation in a column of its own, off the grid at a
|
|
79
|
+
fixed width, and the page on the intrinsic grid of `@canonical/styles`
|
|
80
|
+
(`.grid.intrinsic`), corrected so a phone keeps four columns. Put it in a router
|
|
81
|
+
wrapper every page shares, and it stays mounted while the reader moves.
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
const siteLayout = wrapper({
|
|
85
|
+
id: "site",
|
|
86
|
+
component: ({ children }) => (
|
|
87
|
+
<SiteLayout
|
|
88
|
+
navigation={
|
|
89
|
+
<>
|
|
90
|
+
<CommandPalette search="search" />
|
|
91
|
+
<Navigation />
|
|
92
|
+
</>
|
|
93
|
+
}
|
|
94
|
+
>
|
|
95
|
+
{children}
|
|
96
|
+
</SiteLayout>
|
|
97
|
+
),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const searchRoute = route({ url: "/search", content: () => <SearchPage /> });
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- `Navigation` lists the lenses in their order. A lens's shortcut opens it on
|
|
104
|
+
one key press, unless the reader turned shortcuts off.
|
|
105
|
+
- `CommandPalette` is a link to the search page that, with scripts, opens a
|
|
106
|
+
native `<dialog>` holding one combobox. `/` opens it; Escape closes it and
|
|
107
|
+
gives focus back to the link.
|
|
108
|
+
- `SearchPage` does the palette's job at its own address, reading `?q=`, so
|
|
109
|
+
it works without scripts.
|
|
110
|
+
|
|
111
|
+
## Drawing a thing: four projections on slots
|
|
112
|
+
|
|
113
|
+
Every node of the graph answers the same eight questions, its slots: `label`,
|
|
114
|
+
`category`, `description`, `facts`, `location`, `parent`, `status` and
|
|
115
|
+
`version`, under `_meta.slots`. Four components draw any thing from them, and
|
|
116
|
+
none knows about a specific kind of thing:
|
|
117
|
+
|
|
118
|
+
| Projection | Where | What it shows |
|
|
119
|
+
| --- | --- | --- |
|
|
120
|
+
| `Chip` | In a sentence, or alone | The label, in the design system's chip |
|
|
121
|
+
| `Row` | One line of a list | The label, the category, the status |
|
|
122
|
+
| `Card` | A tile on the grid, in the design system's card | The label, category, location, description, version, status and three facts |
|
|
123
|
+
| `PageHeader` | The top of a thing's page | The parents, the label as the heading, the category, location, version, status and description |
|
|
124
|
+
|
|
125
|
+
A slot a thing does not have takes no room. Each reads its own fragment,
|
|
126
|
+
which a page spreads in its query (`...PrismChip_node`, `...PrismRow_node`,
|
|
127
|
+
`...PrismCard_node`, `...PrismPageHeader_node`), and links the thing to its
|
|
128
|
+
page when its class has a home route: a route whose only param is `:uri`
|
|
129
|
+
and whose `meta.home` names the class. A label with no text is replaced by
|
|
130
|
+
the thing's compact name, then its IRI, so no link or heading is unnamed.
|
|
131
|
+
The projections and their plain views read Relay fragments (a fact or a
|
|
132
|
+
location that names a thing is drawn as that thing's chip), so they render
|
|
133
|
+
inside the site's `RelayEnvironmentProvider` and its `RouterProvider`.
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
const routes = group(siteLayout, {
|
|
137
|
+
component: route({
|
|
138
|
+
url: "/components/:uri",
|
|
139
|
+
content: ComponentPage,
|
|
140
|
+
meta: { lensOf: "components", home: "ds:UIBlock" },
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
function ComponentPage({ params }: { params: { uri: string } }) {
|
|
145
|
+
const { node } = useLazyLoadQuery<ComponentPageQuery>(componentPageQuery, {
|
|
146
|
+
uri: params.uri,
|
|
147
|
+
});
|
|
148
|
+
return node ? <PageHeader node={node} /> : null;
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The home route of a thing is the one for its nearest class that has one, so a
|
|
153
|
+
route home to `ds:UIBlock` shows components and subcomponents alike. A class
|
|
154
|
+
is named by its IRI or by its compact name as the graph gives it
|
|
155
|
+
(`_meta.curie`), one way across the route table: a home route with another
|
|
156
|
+
param, two routes for one class, or one class named both ways on two routes
|
|
157
|
+
is refused with an error. The thing's IRI is the route's `uri`.
|
|
158
|
+
|
|
159
|
+
### Replacing a projection for a class
|
|
160
|
+
|
|
161
|
+
A site replaces any of the four for a class through one map, passed once to
|
|
162
|
+
the `Prism` provider. The keys of each entry are `chip`, `row`, `card` and
|
|
163
|
+
`header`. A replacement receives the props of the plain view it replaces
|
|
164
|
+
(`ChipView`, `RowView`, `CardView`, `PageHeaderView`: the thing's `uri`, its
|
|
165
|
+
`slots` and the name of its `home` route) and can render that view itself.
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
function TokenCard({ children, ...props }: CardViewProps) {
|
|
169
|
+
return (
|
|
170
|
+
<CardView {...props}>
|
|
171
|
+
<TokenSwatch uri={props.uri} />
|
|
172
|
+
{children}
|
|
173
|
+
</CardView>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const overrides = {
|
|
178
|
+
"ds:Token": { card: TokenCard },
|
|
179
|
+
} satisfies ProjectionOverrides;
|
|
180
|
+
|
|
181
|
+
<Prism overrides={overrides}>{/* the site */}</Prism>;
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
A replacement for a class applies to its subclasses, unless a nearer class
|
|
185
|
+
has its own for the same projection. The graph serves each thing's class
|
|
186
|
+
(`_meta.type`) and every ancestor of it (`superclasses`), each with its own
|
|
187
|
+
ancestors. The engine orders them nearest first by how many ancestors each
|
|
188
|
+
has: an ancestor of a class always has fewer, so every class comes before its
|
|
189
|
+
superclasses whatever order the graph lists them in, and ancestors on
|
|
190
|
+
separate branches keep the graph's order. It then takes the first class with
|
|
191
|
+
a replacement. A provider must list every ancestor in `superclasses`, not
|
|
192
|
+
only the direct ones.
|
|
193
|
+
|
|
194
|
+
### Text from the graph
|
|
195
|
+
|
|
196
|
+
The engine reads no markup. `Prose` draws a text from the graph, such as a
|
|
197
|
+
description, and on its own draws it as plain paragraphs, parted on blank
|
|
198
|
+
lines, each trimmed and otherwise as written: no markup is interpreted and
|
|
199
|
+
no link is followed. It needs neither Relay nor a router. A site that wants
|
|
200
|
+
more passes its own component as `Text` to `Prism`, beside `overrides`. It
|
|
201
|
+
receives exactly `{ text, mentions }`: the text untouched, and the things it
|
|
202
|
+
mentions, each a `Mention` with its `uri`, its compact name `curie` and the
|
|
203
|
+
`node` a `Chip` draws. **`mentions` is a seam that nothing fills yet:** the
|
|
204
|
+
contract cannot say which things a text mentions, so the list is always
|
|
205
|
+
empty today, and it fills when the contract can serve them.
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
<Prism overrides={overrides} Text={SiteText}>
|
|
209
|
+
{/* the site */}
|
|
210
|
+
</Prism>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
A docs site's `SiteText` is about ten lines, written for the day mentions
|
|
214
|
+
arrive: it hands `text` to the site's Markdown renderer, and gives that
|
|
215
|
+
renderer one replacement for links. The link replacement calls
|
|
216
|
+
`findMention(mentions, href)`, which today finds nothing; when it finds a thing,
|
|
217
|
+
it draws `<Chip node={mention.node} />`, which shows the thing's own label
|
|
218
|
+
rather than the words of the link, and otherwise it draws an ordinary link.
|
|
219
|
+
`findMention` matches a target by IRI or compact name, as written or
|
|
220
|
+
percent-encoded, reserved characters included. Only links are read this way,
|
|
221
|
+
so a bare `ds:Button` in a sentence stays text. Because `Text` is a
|
|
222
|
+
component, it can use hooks and be memoised.
|
|
223
|
+
|
|
224
|
+
### Finding things
|
|
225
|
+
|
|
226
|
+
`graph` is off by default, and then neither the palette nor the search page
|
|
227
|
+
sends any query. The contract has no `search` field yet, so leave it off
|
|
228
|
+
until it does. With `graph`, the command palette lists the things the graph's `search` field
|
|
229
|
+
finds after the lenses, and the search page lists them below the lenses, each
|
|
230
|
+
drawn as a `Row`. The search route's `warm` fetches them with `warmSearch`,
|
|
231
|
+
given the route's `q`, so the server renders them. On the server the search
|
|
232
|
+
page reads only what `warm` put in the store and never fetches: when the
|
|
233
|
+
answer is not there, because `warm` failed or the route has none, it says
|
|
234
|
+
"Search is unavailable." In the browser, a failed search shows no things in
|
|
235
|
+
the palette, whose lenses still work, and the same sentence on the search
|
|
236
|
+
page; the rest of the page stays.
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
const searchRoute = route({
|
|
240
|
+
url: "/search",
|
|
241
|
+
search: qSchema, // any Standard Schema that reads `q` as a string
|
|
242
|
+
content: () => <SearchPage graph />,
|
|
243
|
+
warm: (_params, { q }, { context, signal }) =>
|
|
244
|
+
warmSearch(context.environment, q, { signal }),
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Compiling the fragments in a site
|
|
249
|
+
|
|
250
|
+
A site's own queries spread the projections' fragments, so its
|
|
251
|
+
relay-compiler must read them. They are in the built package's
|
|
252
|
+
`dist/esm/lib/graphql` folder, with their tags kept; the search query is
|
|
253
|
+
apart, in `dist/esm/lib/searchQuery`, and is added only by a site whose
|
|
254
|
+
schema has the `search` field, since it does not compile without it. A
|
|
255
|
+
single-project relay config takes one source folder, so the site uses a
|
|
256
|
+
multi-project config, and its `excludes` must not exclude `node_modules`
|
|
257
|
+
(relay-compiler's default does):
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"sources": {
|
|
262
|
+
"src": "site",
|
|
263
|
+
"node_modules/@canonical/prism/dist/esm/lib/graphql": "site"
|
|
264
|
+
},
|
|
265
|
+
"excludes": ["**/__generated__/**"],
|
|
266
|
+
"projects": {
|
|
267
|
+
"site": {
|
|
268
|
+
"schema": "schema.graphql",
|
|
269
|
+
"language": "typescript",
|
|
270
|
+
"eagerEsModules": true,
|
|
271
|
+
"output": "src/__generated__",
|
|
272
|
+
"schemaConfig": {
|
|
273
|
+
"nodeInterfaceIdField": "uri",
|
|
274
|
+
"nodeInterfaceIdVariableName": "id"
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
With `graph` on, add `"node_modules/@canonical/prism/dist/esm/lib/searchQuery":
|
|
282
|
+
"site"` to `sources`. The site's schema needs the contract's slots; a test
|
|
283
|
+
compiles exactly this project against the built package.
|
|
284
|
+
|
|
285
|
+
### The schema the projections are written against
|
|
286
|
+
|
|
287
|
+
The contract (`@canonical/prism-contract`) has the slots but not the
|
|
288
|
+
`search` field. The engine's queries are written against the contract with
|
|
289
|
+
the search field, which exists only in `src/testing/schema/search.graphql`.
|
|
290
|
+
`scripts/writeSchema.ts` merges it into the contract for relay-compiler, and
|
|
291
|
+
the tests and stories answer the queries from fixtures through the same
|
|
292
|
+
files. The compiled artifacts are committed, so the package builds with
|
|
293
|
+
`tsc` alone and a site needs no bundler transform.
|
|
294
|
+
|
|
295
|
+
## The server step
|
|
296
|
+
|
|
297
|
+
`renderPage` is one step of the site's server:
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
import { renderPage } from "@canonical/prism/server";
|
|
301
|
+
|
|
302
|
+
export default function page(request: Request, html: string) {
|
|
303
|
+
const { environment, readRecords } = createServerEnvironment({ graphqlUrl });
|
|
304
|
+
|
|
305
|
+
return renderPage(request, {
|
|
306
|
+
routes,
|
|
307
|
+
notFound,
|
|
308
|
+
middleware,
|
|
309
|
+
Shell,
|
|
310
|
+
context: { environment },
|
|
311
|
+
data: () => ({ records: readRecords() }),
|
|
312
|
+
html,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
It answers GET and HEAD (405 otherwise; HEAD gets GET's status and headers
|
|
318
|
+
without a body), applies the site's `middleware` as the browser's router does,
|
|
319
|
+
resolves the redirect or the status,
|
|
320
|
+
waits for the matched routes' `warm`, then streams the document with the
|
|
321
|
+
router state and what `data` returned embedded as `PageData`. One five-second
|
|
322
|
+
deadline bounds the whole answer: when `warm` has not settled by then, the page
|
|
323
|
+
fails closed with a 503, because a `warm` still running may be a guard about to
|
|
324
|
+
redirect; a deadline passing while the shell renders also answers 503, and a
|
|
325
|
+
stream still running at the deadline is cut. Pages carry
|
|
326
|
+
`Cache-Control: private, no-cache`.
|
|
327
|
+
|
|
328
|
+
The site writes its own `Shell` (its providers around the router's outlet,
|
|
329
|
+
receiving `router` and `context`), its own Relay environments and its own
|
|
330
|
+
browser entry, which reads `PageData` from `window[INITIAL_DATA_KEY]` and
|
|
331
|
+
passes `router` to `createRouter` as `hydratedState`.
|
|
332
|
+
|
|
333
|
+
## Exports
|
|
334
|
+
|
|
335
|
+
| Export | From | What it is |
|
|
336
|
+
| --- | --- | --- |
|
|
337
|
+
| `Navigation` | `@canonical/prism` | The list of lenses |
|
|
338
|
+
| `Chip`, `Row`, `Card`, `PageHeader` | `@canonical/prism` | The four projections of a thing |
|
|
339
|
+
| `ChipView`, `RowView`, `CardView`, `PageHeaderView` | `@canonical/prism` | Their plain views, for a replacement to reuse |
|
|
340
|
+
| `Prism`, `ProjectionOverrides` | `@canonical/prism` | The provider of a site's replacements and text component, and the map |
|
|
341
|
+
| `Prose`, `TextProps`, `Mention`, `findMention` | `@canonical/prism` | Text from the graph, the site's text component's props, and the lookup of a link's mentioned thing |
|
|
342
|
+
| `warmSearch` | `@canonical/prism` | Fetches a search ahead of the search page |
|
|
343
|
+
| `SiteLayout` | `@canonical/prism` | The frame: navigation column, header band, page |
|
|
344
|
+
| `CommandPalette` | `@canonical/prism` | The search link and dialog |
|
|
345
|
+
| `SearchPage` | `@canonical/prism` | The search page |
|
|
346
|
+
| `warmQuery` | `@canonical/prism` | Fetches a query ahead of the page, in a route's `warm` |
|
|
347
|
+
| `PrismRouteMeta`, `Lens` | `@canonical/prism` | The route meta Prism reads: `lens`, `lensOf` and `home` |
|
|
348
|
+
| `ShellProps`, `PageData` | `@canonical/prism` | What the site's Shell and browser entry receive |
|
|
349
|
+
| `renderPage`, `RenderPageOptions` | `@canonical/prism/server` | The server step |
|
|
350
|
+
|
|
351
|
+
Each projection and its plain view, the provider and `Prose` export their
|
|
352
|
+
props types.
|
|
353
|
+
|
|
354
|
+
CSS classes start with `prism-`. Every colour, size and space comes from the
|
|
355
|
+
design system's tokens, and the chip and the card are the design system's
|
|
356
|
+
own.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @canonical/prism — the site engine of Prism: a site's navigation, layout,
|
|
3
|
+
* command palette and search page, read from the site's own route table; the
|
|
4
|
+
* four projections that draw any thing of the graph from its slots, and the
|
|
5
|
+
* provider through which a site replaces them, or the component that draws
|
|
6
|
+
* text from the graph; and the helpers its routes fetch their data with.
|
|
7
|
+
* The server step is at `@canonical/prism/server`.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
export { Card, CardView, } from "./lib/Card/index.js";
|
|
12
|
+
export { Chip, ChipView, } from "./lib/Chip/index.js";
|
|
13
|
+
export { CommandPalette, } from "./lib/CommandPalette/index.js";
|
|
14
|
+
export { Navigation } from "./lib/Navigation/index.js";
|
|
15
|
+
export { PageHeader, PageHeaderView, } from "./lib/PageHeader/index.js";
|
|
16
|
+
export { Prism, } from "./lib/Prism/index.js";
|
|
17
|
+
export { findMention, Prose } from "./lib/Prose/index.js";
|
|
18
|
+
export { Row, RowView, } from "./lib/Row/index.js";
|
|
19
|
+
export { SearchPage } from "./lib/SearchPage/index.js";
|
|
20
|
+
export { SiteLayout } from "./lib/SiteLayout/index.js";
|
|
21
|
+
export { warmSearch } from "./lib/search/index.js";
|
|
22
|
+
export { warmQuery } from "./lib/warmQuery/index.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useFragment } from "react-relay";
|
|
3
|
+
import { prismCardFragment } from "../graphql/index.js";
|
|
4
|
+
import { useProjection, withLabel } from "../projection/index.js";
|
|
5
|
+
import CardView from "./CardView.js";
|
|
6
|
+
/**
|
|
7
|
+
* A thing as a card, for any kind of thing: it reads the thing's slots and
|
|
8
|
+
* draws the site's card for the thing's nearest class, or the plain
|
|
9
|
+
* `CardView`.
|
|
10
|
+
*/
|
|
11
|
+
export default function Card({ node, linked = true, ...props }) {
|
|
12
|
+
const data = useFragment(prismCardFragment, node);
|
|
13
|
+
const { uri, Override, home } = useProjection(data, "card");
|
|
14
|
+
const View = Override ?? CardView;
|
|
15
|
+
return (_jsx(View, { ...props, home: linked ? home : undefined, slots: withLabel(data._meta.slots, data._meta.curie, uri), uri: uri }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card as DsCard } from "@canonical/react-ds-global";
|
|
3
|
+
import { FactValue } from "../Fact/index.js";
|
|
4
|
+
import { Prose } from "../Prose/index.js";
|
|
5
|
+
import { ThingLink } from "../ThingLink/index.js";
|
|
6
|
+
import "./styles.css";
|
|
7
|
+
const componentCssClassName = "prism-card";
|
|
8
|
+
/**
|
|
9
|
+
* The plain card, in the design system's card: the thing's label, linked to
|
|
10
|
+
* its page when it has one, its category and location, then its
|
|
11
|
+
* description, and its version, status and facts as a list of terms. A slot
|
|
12
|
+
* the thing does not have takes no room. `children` follow the facts, for an
|
|
13
|
+
* override that adds its own parts.
|
|
14
|
+
*/
|
|
15
|
+
export default function CardView({ uri, slots, home, className, children, ...props }) {
|
|
16
|
+
const { label, category, location, description, version, status, facts } = slots;
|
|
17
|
+
const hasTerms = Boolean(version || status || facts.length > 0);
|
|
18
|
+
return (_jsxs(DsCard, { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [_jsxs(DsCard.Header, { children: [_jsx("p", { className: `${componentCssClassName}-label`, dir: "auto", children: home === undefined ? (label) : (_jsx(ThingLink, { home: home, uri: uri, children: label })) }), _jsxs("p", { className: `${componentCssClassName}-kind`, children: [_jsx("span", { className: `${componentCssClassName}-category`, children: category }), location ? (_jsxs(_Fragment, { children: [" ", _jsx("span", { className: `${componentCssClassName}-location`, children: _jsx(FactValue, { fact: location }) })] })) : null] })] }), description || hasTerms || children ? (_jsxs(DsCard.Content, { children: [description ? _jsx(Prose, { children: description }) : null, hasTerms ? (_jsxs("dl", { className: `${componentCssClassName}-terms`, children: [version ? (_jsxs("div", { children: [_jsx("dt", { children: "Version" }), _jsx("dd", { children: _jsx(FactValue, { fact: version }) })] })) : null, status ? (_jsxs("div", { children: [_jsx("dt", { children: "Status" }), _jsx("dd", { children: _jsx(FactValue, { fact: status }) })] })) : null, facts.map((fact, index) => (_jsxs("div", { children: [_jsx("dt", { children: fact.name }), _jsx("dd", { children: _jsx(FactValue, { fact: fact }) })] }, `${index}-${fact.name}`)))] })) : null, children] })) : null] }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* The design system's card, four columns wide on the intrinsic grid (two
|
|
2
|
+
* side by side from eight columns, with no breakpoint), unless a `Cards`
|
|
3
|
+
* group gives it another span. Inside it, one size
|
|
4
|
+
* of text on the 8px rhythm: the label in ink, the category in the muted
|
|
5
|
+
* colour and the location in ink after it (a location is where a thing
|
|
6
|
+
* lives, worth reading; a category is what it is, already implied), and the
|
|
7
|
+
* terms as tight rows parted by hairlines. */
|
|
8
|
+
|
|
9
|
+
/* Layer: lib, the layer @canonical/styles keeps for a library outside the
|
|
10
|
+
* design system, above every design-system layer and below the site's app. */
|
|
11
|
+
@layer lib {
|
|
12
|
+
.prism-card {
|
|
13
|
+
grid-column: span var(--card-span, 4);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.prism-card-label,
|
|
17
|
+
.prism-card-kind {
|
|
18
|
+
margin: 0;
|
|
19
|
+
line-height: var(--space-300);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.prism-card-kind {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-wrap: wrap;
|
|
25
|
+
column-gap: var(--space-100);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.prism-card-label {
|
|
29
|
+
overflow-wrap: anywhere;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.prism-card-category {
|
|
33
|
+
color: var(--color-text-muted);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.prism-card-location {
|
|
37
|
+
color: var(--color-text);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.prism-card-terms {
|
|
41
|
+
display: grid;
|
|
42
|
+
margin: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
* + .prism-card-terms {
|
|
46
|
+
margin-block-start: var(--space-200);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.prism-card-terms > div {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-wrap: wrap;
|
|
52
|
+
column-gap: var(--space-200);
|
|
53
|
+
padding-block: var(--space-100);
|
|
54
|
+
border-block-start: var(--dimension-stroke-thickness-medium) solid
|
|
55
|
+
var(--color-border-muted);
|
|
56
|
+
line-height: var(--space-300);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.prism-card-terms dt {
|
|
60
|
+
color: var(--color-text-muted);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.prism-card-terms dd {
|
|
64
|
+
margin: 0;
|
|
65
|
+
min-inline-size: 0;
|
|
66
|
+
overflow-wrap: anywhere;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useFragment } from "react-relay";
|
|
3
|
+
import { prismChipFragment } from "../graphql/index.js";
|
|
4
|
+
import { useProjection, withLabel } from "../projection/index.js";
|
|
5
|
+
import ChipView from "./ChipView.js";
|
|
6
|
+
/**
|
|
7
|
+
* A thing as a chip, for any kind of thing: it reads the thing's slots and
|
|
8
|
+
* draws the site's chip for the thing's nearest class, or the plain
|
|
9
|
+
* `ChipView`.
|
|
10
|
+
*/
|
|
11
|
+
export default function Chip({ node, linked = true, ...props }) {
|
|
12
|
+
const data = useFragment(prismChipFragment, node);
|
|
13
|
+
const { uri, Override, home } = useProjection(data, "chip");
|
|
14
|
+
const View = Override ?? ChipView;
|
|
15
|
+
return (_jsx(View, { ...props, home: linked ? home : undefined, slots: withLabel(data._meta.slots, data._meta.curie, uri), uri: uri }));
|
|
16
|
+
}
|