@haxtheweb/primer-theme 0.0.0-stage → 26.8.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/.dddignore +36 -0
- package/.editorconfig +29 -0
- package/.github/workflows/main.yml +33 -0
- package/.nojekyll +0 -0
- package/.surgeignore +1 -0
- package/.travis.yml +15 -0
- package/LICENSE +201 -0
- package/NOTICE +41 -0
- package/README.md +45 -2
- package/custom-elements.json +310 -0
- package/demo/files/thumb-a11y.svg +1 -0
- package/demo/files/thumb-banner.svg +1 -0
- package/demo/files/thumb-button.svg +1 -0
- package/demo/files/thumb-code.svg +1 -0
- package/demo/files/thumb-color.svg +1 -0
- package/demo/files/thumb-type.svg +1 -0
- package/demo/index.html +49 -0
- package/demo/pages/item-b7d4e9a1-accessibility/index.html +6 -0
- package/demo/pages/item-b7d4e9a1-components/index.html +4 -0
- package/demo/pages/item-b7d4e9a1-components-banner/index.html +8 -0
- package/demo/pages/item-b7d4e9a1-components-button/index.html +9 -0
- package/demo/pages/item-b7d4e9a1-foundations/index.html +4 -0
- package/demo/pages/item-b7d4e9a1-foundations-color/index.html +8 -0
- package/demo/pages/item-b7d4e9a1-foundations-typography/index.html +5 -0
- package/demo/pages/item-b7d4e9a1-getting-started/index.html +7 -0
- package/demo/pages/item-b7d4e9a1-getting-started-developing/index.html +14 -0
- package/demo/site.json +231 -0
- package/design-system/bridge.json +498 -0
- package/gulpfile.cjs +14 -0
- package/icons/alert.svg +1 -0
- package/icons/apps.svg +1 -0
- package/icons/archive.svg +1 -0
- package/icons/arrow-down.svg +1 -0
- package/icons/arrow-left.svg +1 -0
- package/icons/arrow-right.svg +1 -0
- package/icons/arrow-switch.svg +1 -0
- package/icons/arrow-up.svg +1 -0
- package/icons/bold.svg +1 -0
- package/icons/book.svg +1 -0
- package/icons/bookmark.svg +1 -0
- package/icons/briefcase.svg +1 -0
- package/icons/calendar.svg +1 -0
- package/icons/check-circle.svg +1 -0
- package/icons/check.svg +1 -0
- package/icons/checklist.svg +1 -0
- package/icons/chevron-down.svg +1 -0
- package/icons/chevron-left.svg +1 -0
- package/icons/chevron-right.svg +1 -0
- package/icons/chevron-up.svg +1 -0
- package/icons/clock.svg +1 -0
- package/icons/cloud.svg +1 -0
- package/icons/code.svg +1 -0
- package/icons/columns.svg +1 -0
- package/icons/comment-discussion.svg +1 -0
- package/icons/comment.svg +1 -0
- package/icons/copy.svg +1 -0
- package/icons/dash.svg +1 -0
- package/icons/device-desktop.svg +1 -0
- package/icons/device-mobile.svg +1 -0
- package/icons/download.svg +1 -0
- package/icons/eye-closed.svg +1 -0
- package/icons/eye.svg +1 -0
- package/icons/file-directory-open-fill.svg +1 -0
- package/icons/file-directory.svg +1 -0
- package/icons/file.svg +1 -0
- package/icons/gear.svg +1 -0
- package/icons/globe.svg +1 -0
- package/icons/graph.svg +1 -0
- package/icons/heading.svg +1 -0
- package/icons/history.svg +1 -0
- package/icons/home.svg +1 -0
- package/icons/image.svg +1 -0
- package/icons/info.svg +1 -0
- package/icons/italic.svg +1 -0
- package/icons/light-bulb.svg +1 -0
- package/icons/link-external.svg +1 -0
- package/icons/link.svg +1 -0
- package/icons/list-ordered.svg +1 -0
- package/icons/list-unordered.svg +1 -0
- package/icons/location.svg +1 -0
- package/icons/lock.svg +1 -0
- package/icons/mail.svg +1 -0
- package/icons/move-to-end.svg +1 -0
- package/icons/move-to-start.svg +1 -0
- package/icons/paperclip.svg +1 -0
- package/icons/pencil.svg +1 -0
- package/icons/people.svg +1 -0
- package/icons/person.svg +1 -0
- package/icons/play.svg +1 -0
- package/icons/plug.svg +1 -0
- package/icons/plus-circle.svg +1 -0
- package/icons/plus.svg +1 -0
- package/icons/question.svg +1 -0
- package/icons/quote.svg +1 -0
- package/icons/redo.svg +1 -0
- package/icons/report.svg +1 -0
- package/icons/rss.svg +1 -0
- package/icons/screen-full.svg +1 -0
- package/icons/search.svg +1 -0
- package/icons/share.svg +1 -0
- package/icons/shield-check.svg +1 -0
- package/icons/sign-out.svg +1 -0
- package/icons/sliders.svg +1 -0
- package/icons/smiley.svg +1 -0
- package/icons/sort-desc.svg +1 -0
- package/icons/star.svg +1 -0
- package/icons/stop.svg +1 -0
- package/icons/strikethrough.svg +1 -0
- package/icons/sync.svg +1 -0
- package/icons/table.svg +1 -0
- package/icons/tag.svg +1 -0
- package/icons/three-bars.svg +1 -0
- package/icons/thumbsup.svg +1 -0
- package/icons/trash.svg +1 -0
- package/icons/triangle-down.svg +1 -0
- package/icons/undo.svg +1 -0
- package/icons/upload.svg +1 -0
- package/icons/video.svg +1 -0
- package/icons/x-circle.svg +1 -0
- package/icons/x.svg +1 -0
- package/icons/zoom-in.svg +1 -0
- package/icons/zoom-out.svg +1 -0
- package/lib/PrimerDDDMap.js +147 -0
- package/lib/PrimerDesignSystem.js +43 -0
- package/lib/PrimerIcons.js +144 -0
- package/lib/PrimerTokens.js +97 -0
- package/lib/primer-theme.docs.json +43 -0
- package/lib/primer.ddd-map.json +1292 -0
- package/locales/primer-theme.en.json +9 -0
- package/package.json +56 -4
- package/primer-theme.js +495 -0
- package/test/primer-theme.test.js +73 -0
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haxtheweb/primer-theme",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "26.8.0",
|
|
4
|
+
"description": "GitHub Primer theme for HAXcms, built on the DDD-capable Primer design system bridge",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/haxtheweb/webcomponents.git"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "primer-theme.js",
|
|
11
|
+
"module": "primer-theme.js",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"start": "yarn run dev",
|
|
14
|
+
"build": "prettier --ignore-path ../../.prettierignore --write \"**/*.{js,json}\" && cem analyze --litelement --exclude \"(public|*.stories.js)\" --globs \"{*,lib/**}.js\" && node ../../scripts/extract-element-docs.mjs --write .",
|
|
15
|
+
"dev": "concurrently --kill-others \"yarn run watch\" \"yarn run serve\"",
|
|
16
|
+
"watch": "gulp dev --gulpfile=gulpfile.cjs",
|
|
17
|
+
"serve": "web-dev-server -c ../../web-dev-server.config.mjs",
|
|
18
|
+
"lighthouse": "gulp lighthouse --gulpfile=gulpfile.cjs",
|
|
19
|
+
"test:watch": "web-test-runner \"test/**/*.test.js\" --node-resolve --config=../../web-test-runner.config.mjs --playwright --browsers chromium --watch",
|
|
20
|
+
"test": "web-test-runner \"test/**/*.test.js\" --coverage --node-resolve --config=../../web-test-runner.config.mjs --playwright --browsers chromium",
|
|
21
|
+
"bridge": "node ../d-d-d/design-system/bridge/build-bridge.js ."
|
|
22
|
+
},
|
|
23
|
+
"author": {
|
|
24
|
+
"name": "haxtheweb",
|
|
25
|
+
"url": "https://hax.psu.edu/"
|
|
26
|
+
},
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@haxtheweb/d-d-d": "^26.8.0",
|
|
30
|
+
"@haxtheweb/haxcms-elements": "^26.8.0",
|
|
31
|
+
"@haxtheweb/i18n-manager": "^26.8.0",
|
|
32
|
+
"@haxtheweb/simple-icon": "^26.8.0",
|
|
33
|
+
"lit": "3.3.3",
|
|
34
|
+
"mobx": "6.16.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@custom-elements-manifest/analyzer": "0.11.0",
|
|
38
|
+
"@haxtheweb/deduping-fix": "^26.8.0",
|
|
39
|
+
"@open-wc/testing": "4.0.0",
|
|
40
|
+
"@web/dev-server": "0.4.6",
|
|
41
|
+
"concurrently": "9.2.5"
|
|
42
|
+
},
|
|
43
|
+
"private": false,
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"customElements": "custom-elements.json",
|
|
48
|
+
"keywords": [
|
|
49
|
+
"webcomponents",
|
|
50
|
+
"html",
|
|
51
|
+
"haxtheweb",
|
|
52
|
+
"lit",
|
|
53
|
+
"haxcms",
|
|
54
|
+
"theme",
|
|
55
|
+
"design-system",
|
|
56
|
+
"primer"
|
|
57
|
+
]
|
|
58
|
+
}
|
package/primer-theme.js
ADDED
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 The Pennsylvania State University
|
|
3
|
+
* @license Apache-2.0, see LICENSE for full text.
|
|
4
|
+
*/
|
|
5
|
+
import { html, css } from "lit";
|
|
6
|
+
import { HAXCMSLitElementTheme } from "@haxtheweb/haxcms-elements/lib/core/HAXCMSLitElementTheme.js";
|
|
7
|
+
import { HAXCMSThemeParts } from "@haxtheweb/haxcms-elements/lib/core/utils/HAXCMSThemeParts.js";
|
|
8
|
+
import { store } from "@haxtheweb/haxcms-elements/lib/core/haxcms-site-store.js";
|
|
9
|
+
import { DDDSuper } from "@haxtheweb/d-d-d/d-d-d.js";
|
|
10
|
+
import { I18NManagerStore } from "@haxtheweb/i18n-manager/lib/I18NMixin.js";
|
|
11
|
+
import { PrimerTokens } from "@haxtheweb/primer-theme/lib/PrimerTokens.js";
|
|
12
|
+
import { PrimerDDDMap } from "@haxtheweb/primer-theme/lib/PrimerDDDMap.js";
|
|
13
|
+
import { activatePrimerDesignSystem } from "@haxtheweb/primer-theme/lib/PrimerDesignSystem.js";
|
|
14
|
+
import { autorun, toJS } from "mobx";
|
|
15
|
+
import "@haxtheweb/haxcms-elements/lib/ui-components/site/site-title.js";
|
|
16
|
+
import "@haxtheweb/haxcms-elements/lib/ui-components/navigation/site-menu.js";
|
|
17
|
+
import "@haxtheweb/simple-icon/simple-icon.js";
|
|
18
|
+
import "@haxtheweb/simple-icon/lib/simple-icons.js";
|
|
19
|
+
import "@haxtheweb/simple-icon/lib/simple-icon-button-lite.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* `primer-theme`
|
|
23
|
+
* A HAXcms theme in the layout of the Primer documentation site: a 64px
|
|
24
|
+
* header on the default background with a hairline border, a NavList
|
|
25
|
+
* sidebar whose current item is a muted pill with Primer's accent bar, and
|
|
26
|
+
* page content in a 1012px column with a muted lead. Built on the Primer
|
|
27
|
+
* DDD bridge: every HAX block reads --ddd-* tokens, which point at Primer
|
|
28
|
+
* tokens while this theme is active.
|
|
29
|
+
*
|
|
30
|
+
* @title Primer
|
|
31
|
+
* @haxcms-theme-category Website, Course, Documentation
|
|
32
|
+
* @haxcms-theme-priority 50
|
|
33
|
+
* @demo demo/index.html
|
|
34
|
+
* @element primer-theme
|
|
35
|
+
*/
|
|
36
|
+
class PrimerTheme extends HAXCMSThemeParts(DDDSuper(HAXCMSLitElementTheme)) {
|
|
37
|
+
static get tag() {
|
|
38
|
+
return "primer-theme";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
HAXCMSGlobalStyleSheetContent() {
|
|
42
|
+
return [
|
|
43
|
+
...super.HAXCMSGlobalStyleSheetContent(),
|
|
44
|
+
css`
|
|
45
|
+
body {
|
|
46
|
+
margin: 0;
|
|
47
|
+
background-color: light-dark(#ffffff, #0d1117);
|
|
48
|
+
}
|
|
49
|
+
`,
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
constructor() {
|
|
54
|
+
super();
|
|
55
|
+
this.t = this.t || {};
|
|
56
|
+
this.t = {
|
|
57
|
+
...this.t,
|
|
58
|
+
skipToContent: "Skip to content",
|
|
59
|
+
toggleSiteMenu: "Toggle site menu",
|
|
60
|
+
siteNavigation: "Site navigation",
|
|
61
|
+
searchSite: "Search site",
|
|
62
|
+
search: "Search",
|
|
63
|
+
toggleDarkMode: "Toggle dark mode",
|
|
64
|
+
pageNavigation: "Page navigation",
|
|
65
|
+
};
|
|
66
|
+
// no I18NMixin in this class chain, so register with the store directly
|
|
67
|
+
I18NManagerStore.registerLocalization({
|
|
68
|
+
context: this,
|
|
69
|
+
localesPath: new URL("./locales/", import.meta.url).href,
|
|
70
|
+
});
|
|
71
|
+
this.HAXCMSThemeSettings.autoScroll = true;
|
|
72
|
+
this.sidebarOpen = true;
|
|
73
|
+
this._mobile = false;
|
|
74
|
+
this.__primerDisposers = [];
|
|
75
|
+
activatePrimerDesignSystem();
|
|
76
|
+
// prettier-ignore
|
|
77
|
+
import(
|
|
78
|
+
"@haxtheweb/haxcms-elements/lib/ui-components/navigation/site-breadcrumb.js"
|
|
79
|
+
);
|
|
80
|
+
// prettier-ignore
|
|
81
|
+
import(
|
|
82
|
+
"@haxtheweb/haxcms-elements/lib/ui-components/active-item/site-active-title.js"
|
|
83
|
+
);
|
|
84
|
+
// prettier-ignore
|
|
85
|
+
import(
|
|
86
|
+
"@haxtheweb/haxcms-elements/lib/ui-components/navigation/site-menu-button.js"
|
|
87
|
+
);
|
|
88
|
+
// prettier-ignore
|
|
89
|
+
import(
|
|
90
|
+
"@haxtheweb/haxcms-elements/lib/ui-components/layout/site-modal.js"
|
|
91
|
+
);
|
|
92
|
+
// prettier-ignore
|
|
93
|
+
import(
|
|
94
|
+
"@haxtheweb/haxcms-elements/lib/ui-components/site/site-search.js"
|
|
95
|
+
);
|
|
96
|
+
// prettier-ignore
|
|
97
|
+
import(
|
|
98
|
+
"@haxtheweb/haxcms-elements/lib/ui-components/layout/site-region.js"
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static get properties() {
|
|
103
|
+
return {
|
|
104
|
+
...super.properties,
|
|
105
|
+
sidebarOpen: { type: Boolean, reflect: true, attribute: "sidebar-open" },
|
|
106
|
+
_mobile: { type: Boolean, state: true },
|
|
107
|
+
_dark: { type: Boolean, state: true },
|
|
108
|
+
_lead: { type: String, state: true },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static get styles() {
|
|
113
|
+
return [
|
|
114
|
+
super.styles,
|
|
115
|
+
PrimerTokens,
|
|
116
|
+
PrimerDDDMap,
|
|
117
|
+
css`
|
|
118
|
+
:host {
|
|
119
|
+
display: block;
|
|
120
|
+
min-height: 100vh;
|
|
121
|
+
color: var(--fgColor-default);
|
|
122
|
+
background-color: var(--bgColor-default);
|
|
123
|
+
font-family: var(--ddd-font-primary);
|
|
124
|
+
--primer-theme-header-height: 64px;
|
|
125
|
+
--primer-theme-nav-width: 272px;
|
|
126
|
+
}
|
|
127
|
+
:host([hidden]) {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
130
|
+
/* Primer's focus: a 2px outline in the focus color, -2px inset on
|
|
131
|
+
controls and 0 on links so it stays visible around text */
|
|
132
|
+
a:focus-visible,
|
|
133
|
+
button:focus-visible,
|
|
134
|
+
simple-icon-button-lite:focus-visible {
|
|
135
|
+
outline: 2px solid var(--focus-outlineColor);
|
|
136
|
+
outline-offset: -2px;
|
|
137
|
+
border-radius: 6px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* header */
|
|
141
|
+
.header {
|
|
142
|
+
position: sticky;
|
|
143
|
+
top: 0;
|
|
144
|
+
z-index: 3;
|
|
145
|
+
display: flex;
|
|
146
|
+
align-items: center;
|
|
147
|
+
gap: var(--ddd-spacing-2);
|
|
148
|
+
height: var(--primer-theme-header-height);
|
|
149
|
+
padding: 0 var(--ddd-spacing-4);
|
|
150
|
+
box-sizing: border-box;
|
|
151
|
+
background-color: var(--bgColor-default);
|
|
152
|
+
color: var(--fgColor-default);
|
|
153
|
+
border-bottom: 1px solid var(--borderColor-default);
|
|
154
|
+
}
|
|
155
|
+
.header-name {
|
|
156
|
+
flex: 1 1 auto;
|
|
157
|
+
min-width: 0;
|
|
158
|
+
}
|
|
159
|
+
site-title {
|
|
160
|
+
--site-title-link-text-decoration: none;
|
|
161
|
+
--site-title-heading-font-size: var(--ddd-font-size-4xs);
|
|
162
|
+
--site-title-heading-font-weight: var(--base-text-weight-semibold);
|
|
163
|
+
--site-title-heading-margin: 0;
|
|
164
|
+
--site-title-link-display: inline;
|
|
165
|
+
--site-title-link-color: var(--fgColor-default);
|
|
166
|
+
color: var(--fgColor-default);
|
|
167
|
+
}
|
|
168
|
+
.header-action,
|
|
169
|
+
site-modal {
|
|
170
|
+
--simple-icon-width: 16px;
|
|
171
|
+
--simple-icon-height: 16px;
|
|
172
|
+
--simple-icon-button-border-radius: 6px;
|
|
173
|
+
--site-modal-icon-color: var(--fgColor-muted);
|
|
174
|
+
color: var(--fgColor-muted);
|
|
175
|
+
}
|
|
176
|
+
/* Primer IconButton (invisible variant): 32px, 6px corners, no
|
|
177
|
+
border or fill until hovered */
|
|
178
|
+
.header-action {
|
|
179
|
+
width: 32px;
|
|
180
|
+
height: 32px;
|
|
181
|
+
border-radius: 6px;
|
|
182
|
+
}
|
|
183
|
+
.header-action:hover,
|
|
184
|
+
.header-action:focus-visible {
|
|
185
|
+
background-color: var(--control-transparent-bgColor-hover);
|
|
186
|
+
color: var(--fgColor-default);
|
|
187
|
+
}
|
|
188
|
+
.header-actions {
|
|
189
|
+
display: flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
gap: var(--ddd-spacing-2);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* NavList sidebar + content */
|
|
195
|
+
.shell {
|
|
196
|
+
display: flex;
|
|
197
|
+
align-items: flex-start;
|
|
198
|
+
}
|
|
199
|
+
.nav {
|
|
200
|
+
position: sticky;
|
|
201
|
+
top: var(--primer-theme-header-height);
|
|
202
|
+
flex: 0 0 var(--primer-theme-nav-width);
|
|
203
|
+
width: var(--primer-theme-nav-width);
|
|
204
|
+
height: calc(100vh - var(--primer-theme-header-height));
|
|
205
|
+
overflow-y: auto;
|
|
206
|
+
padding: var(--ddd-spacing-4) var(--ddd-spacing-2);
|
|
207
|
+
box-sizing: border-box;
|
|
208
|
+
background-color: var(--bgColor-default);
|
|
209
|
+
border-right: 1px solid var(--borderColor-default);
|
|
210
|
+
}
|
|
211
|
+
:host(:not([sidebar-open])) .nav {
|
|
212
|
+
display: none;
|
|
213
|
+
}
|
|
214
|
+
site-menu {
|
|
215
|
+
height: auto;
|
|
216
|
+
--site-menu-background-color: transparent;
|
|
217
|
+
--site-menu-container-background-color: transparent;
|
|
218
|
+
--site-menu-color: var(--fgColor-default);
|
|
219
|
+
--site-menu-font-size: var(--ddd-font-size-4xs);
|
|
220
|
+
--map-menu-container-padding: 0;
|
|
221
|
+
--map-menu-gap: 2px;
|
|
222
|
+
--map-menu-item-border-radius: 6px;
|
|
223
|
+
--map-menu-item-a-color: var(--fgColor-default);
|
|
224
|
+
--map-menu-item-a-active-color: var(--fgColor-default);
|
|
225
|
+
--map-menu-item-a-active-background-color: var(
|
|
226
|
+
--control-transparent-bgColor-selected
|
|
227
|
+
);
|
|
228
|
+
/* the current-item background is translucent, so the check on a
|
|
229
|
+
done progress disc is drawn in the opaque page background */
|
|
230
|
+
--map-menu-progress-ring-on-color: var(--bgColor-default);
|
|
231
|
+
--map-menu-item-active-item-color: var(--fgColor-default);
|
|
232
|
+
/* NavList marks the current item with a 4px accent bar */
|
|
233
|
+
--map-menu-item-active-accent-width: 4px;
|
|
234
|
+
--map-menu-item-active-accent-color: var(--fgColor-accent);
|
|
235
|
+
--map-menu-item-icon-active-color: var(--fgColor-default);
|
|
236
|
+
--map-menu-item-button-active-font-weight: var(
|
|
237
|
+
--base-text-weight-semibold
|
|
238
|
+
);
|
|
239
|
+
--map-menu-font-weight: var(--ddd-font-weight-regular);
|
|
240
|
+
--map-menu-parent-background-color: transparent;
|
|
241
|
+
--map-menu-header-title-margin: var(--ddd-spacing-4);
|
|
242
|
+
font-family: var(--ddd-font-primary);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
main {
|
|
246
|
+
flex: 1 1 auto;
|
|
247
|
+
min-width: 0;
|
|
248
|
+
min-height: calc(100vh - var(--primer-theme-header-height));
|
|
249
|
+
display: flex;
|
|
250
|
+
flex-direction: column;
|
|
251
|
+
}
|
|
252
|
+
.page-header {
|
|
253
|
+
padding: var(--ddd-spacing-10) var(--ddd-spacing-12)
|
|
254
|
+
var(--ddd-spacing-6);
|
|
255
|
+
max-width: var(--primer-theme-content-max-width, 1012px);
|
|
256
|
+
box-sizing: border-box;
|
|
257
|
+
width: 100%;
|
|
258
|
+
}
|
|
259
|
+
site-breadcrumb {
|
|
260
|
+
--site-breadcrumb-margin: 0 0 var(--ddd-spacing-2) 0;
|
|
261
|
+
--site-breadcrumb-font-size: var(--ddd-font-size-4xs);
|
|
262
|
+
--site-breadcrumb-color: var(--fgColor-accent);
|
|
263
|
+
--site-breadcrumb-color-hover: var(--fgColor-accent);
|
|
264
|
+
--site-breadcrumb-last-color: var(--fgColor-muted);
|
|
265
|
+
--site-breadcrumb-separator-color: var(--fgColor-muted);
|
|
266
|
+
}
|
|
267
|
+
site-active-title {
|
|
268
|
+
--site-active-title-margin: 0;
|
|
269
|
+
--site-active-title-padding: 0;
|
|
270
|
+
}
|
|
271
|
+
site-active-title h1 {
|
|
272
|
+
margin: 0;
|
|
273
|
+
font-family: var(--ddd-font-primary);
|
|
274
|
+
font-size: var(--ddd-font-size-xl);
|
|
275
|
+
font-weight: var(--base-text-weight-semibold);
|
|
276
|
+
line-height: 1.25;
|
|
277
|
+
color: var(--fgColor-default);
|
|
278
|
+
}
|
|
279
|
+
/* the page description as Primer's muted lead under a hairline */
|
|
280
|
+
.lead {
|
|
281
|
+
max-width: 40rem;
|
|
282
|
+
margin: var(--ddd-spacing-2) 0 0;
|
|
283
|
+
font-size: var(--ddd-font-size-xs);
|
|
284
|
+
line-height: 1.5;
|
|
285
|
+
color: var(--fgColor-muted);
|
|
286
|
+
}
|
|
287
|
+
.page-header::after {
|
|
288
|
+
content: "";
|
|
289
|
+
display: block;
|
|
290
|
+
margin-top: var(--ddd-spacing-6);
|
|
291
|
+
border-bottom: 1px solid var(--borderColor-muted);
|
|
292
|
+
}
|
|
293
|
+
.content {
|
|
294
|
+
padding: 0 var(--ddd-spacing-12);
|
|
295
|
+
max-width: var(--primer-theme-content-max-width, 1012px);
|
|
296
|
+
box-sizing: border-box;
|
|
297
|
+
width: 100%;
|
|
298
|
+
flex: 1 1 auto;
|
|
299
|
+
}
|
|
300
|
+
#slot {
|
|
301
|
+
padding: 0;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/* previous / next as Primer default buttons */
|
|
305
|
+
.pager {
|
|
306
|
+
display: flex;
|
|
307
|
+
justify-content: space-between;
|
|
308
|
+
gap: var(--ddd-spacing-4);
|
|
309
|
+
max-width: var(--primer-theme-content-max-width, 1012px);
|
|
310
|
+
box-sizing: border-box;
|
|
311
|
+
margin-top: var(--ddd-spacing-12);
|
|
312
|
+
padding: var(--ddd-spacing-6) var(--ddd-spacing-12);
|
|
313
|
+
}
|
|
314
|
+
site-menu-button {
|
|
315
|
+
--site-menu-button-icon-fill-color: var(--fgColor-default);
|
|
316
|
+
--site-menu-button-link-color: var(--fgColor-default);
|
|
317
|
+
--site-menu-button-link-decoration: none;
|
|
318
|
+
--site-menu-button-button-border-radius: 6px;
|
|
319
|
+
--site-menu-button-button-hover-background-color: var(
|
|
320
|
+
--button-default-bgColor-hover
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
site-menu-button[disabled] {
|
|
324
|
+
visibility: hidden;
|
|
325
|
+
}
|
|
326
|
+
footer {
|
|
327
|
+
padding: var(--ddd-spacing-6) var(--ddd-spacing-12);
|
|
328
|
+
color: var(--fgColor-muted);
|
|
329
|
+
font-size: var(--ddd-font-size-4xs);
|
|
330
|
+
border-top: 1px solid var(--borderColor-default);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
:host([edit-mode]) .header-actions,
|
|
334
|
+
:host([edit-mode]) .pager {
|
|
335
|
+
opacity: 0.4;
|
|
336
|
+
pointer-events: none;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/* below Primer's large breakpoint (1012px) the sidebar overlays */
|
|
340
|
+
@media (max-width: 1011px) {
|
|
341
|
+
.nav {
|
|
342
|
+
position: fixed;
|
|
343
|
+
left: 0;
|
|
344
|
+
top: var(--primer-theme-header-height);
|
|
345
|
+
z-index: 2;
|
|
346
|
+
box-shadow: var(--shadow-floating-small);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
@media (max-width: 543px) {
|
|
350
|
+
.page-header {
|
|
351
|
+
padding: var(--ddd-spacing-8) var(--ddd-spacing-4)
|
|
352
|
+
var(--ddd-spacing-4);
|
|
353
|
+
}
|
|
354
|
+
.content,
|
|
355
|
+
.pager,
|
|
356
|
+
footer {
|
|
357
|
+
padding-left: var(--ddd-spacing-4);
|
|
358
|
+
padding-right: var(--ddd-spacing-4);
|
|
359
|
+
}
|
|
360
|
+
.nav {
|
|
361
|
+
width: min(var(--primer-theme-nav-width), 85vw);
|
|
362
|
+
}
|
|
363
|
+
site-active-title h1 {
|
|
364
|
+
font-size: var(--ddd-font-size-l);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
@media (prefers-reduced-motion: reduce) {
|
|
368
|
+
* {
|
|
369
|
+
transition: none !important;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
`,
|
|
373
|
+
];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
render() {
|
|
377
|
+
return html`
|
|
378
|
+
<a class="skip-link" href="#contentcontainer">${this.t.skipToContent}</a>
|
|
379
|
+
<header class="header" part="header">
|
|
380
|
+
<simple-icon-button-lite
|
|
381
|
+
class="header-action"
|
|
382
|
+
icon="${this.sidebarOpen ? "close" : "menu"}"
|
|
383
|
+
title="${this.t.toggleSiteMenu}"
|
|
384
|
+
aria-expanded="${this.sidebarOpen ? "true" : "false"}"
|
|
385
|
+
aria-controls="nav"
|
|
386
|
+
@click="${this.toggleSidebar}"
|
|
387
|
+
></simple-icon-button-lite>
|
|
388
|
+
<div class="header-name">
|
|
389
|
+
<site-title
|
|
390
|
+
?disabled="${this.editMode}"
|
|
391
|
+
part="site-title"
|
|
392
|
+
></site-title>
|
|
393
|
+
</div>
|
|
394
|
+
<div class="header-actions">
|
|
395
|
+
<site-modal
|
|
396
|
+
class="header-action"
|
|
397
|
+
?disabled="${this.editMode}"
|
|
398
|
+
icon="icons:search"
|
|
399
|
+
title="${this.t.searchSite}"
|
|
400
|
+
button-label="${this.t.search}"
|
|
401
|
+
part="search-btn"
|
|
402
|
+
>
|
|
403
|
+
<site-search></site-search>
|
|
404
|
+
</site-modal>
|
|
405
|
+
<simple-icon-button-lite
|
|
406
|
+
class="header-action"
|
|
407
|
+
icon="${this._dark ? "image:brightness-7" : "image:brightness-3"}"
|
|
408
|
+
title="${this.t.toggleDarkMode}"
|
|
409
|
+
aria-pressed="${this._dark ? "true" : "false"}"
|
|
410
|
+
@click="${this.toggleDarkMode}"
|
|
411
|
+
part="dark-mode-btn"
|
|
412
|
+
></simple-icon-button-lite>
|
|
413
|
+
</div>
|
|
414
|
+
</header>
|
|
415
|
+
<div class="shell">
|
|
416
|
+
<div class="nav" id="nav" part="sidenav" ?inert="${!this.sidebarOpen}">
|
|
417
|
+
<nav aria-label="${this.t.siteNavigation}">
|
|
418
|
+
<site-menu part="site-menu"></site-menu>
|
|
419
|
+
</nav>
|
|
420
|
+
</div>
|
|
421
|
+
<main>
|
|
422
|
+
<div class="page-header" part="page-header">
|
|
423
|
+
<site-breadcrumb part="page-breadcrumb"></site-breadcrumb>
|
|
424
|
+
<site-active-title part="page-title"></site-active-title>
|
|
425
|
+
${this._lead ? html`<p class="lead">${this._lead}</p>` : ""}
|
|
426
|
+
</div>
|
|
427
|
+
<div class="content">
|
|
428
|
+
<article id="contentcontainer">
|
|
429
|
+
<section id="slot"><slot></slot></section>
|
|
430
|
+
</article>
|
|
431
|
+
</div>
|
|
432
|
+
<nav class="pager" aria-label="${this.t.pageNavigation}">
|
|
433
|
+
<site-menu-button type="prev" position="right"></site-menu-button>
|
|
434
|
+
<site-menu-button type="next" position="left"></site-menu-button>
|
|
435
|
+
</nav>
|
|
436
|
+
<footer part="footer">
|
|
437
|
+
<site-region name="footerPrimary"></site-region>
|
|
438
|
+
</footer>
|
|
439
|
+
</main>
|
|
440
|
+
</div>
|
|
441
|
+
`;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
connectedCallback() {
|
|
445
|
+
super.connectedCallback();
|
|
446
|
+
this.__mq = globalThis.matchMedia("(max-width: 1011px)");
|
|
447
|
+
this.__mqHandler = (e) => {
|
|
448
|
+
this._mobile = e.matches;
|
|
449
|
+
// the drawer overlays the page on small screens, so start closed
|
|
450
|
+
this.sidebarOpen = !e.matches;
|
|
451
|
+
};
|
|
452
|
+
this.__mq.addEventListener("change", this.__mqHandler);
|
|
453
|
+
this.__mqHandler(this.__mq);
|
|
454
|
+
this.__primerDisposers.push(
|
|
455
|
+
autorun(() => {
|
|
456
|
+
this._dark = !!toJS(store.darkMode);
|
|
457
|
+
}),
|
|
458
|
+
);
|
|
459
|
+
this.__primerDisposers.push(
|
|
460
|
+
autorun(() => {
|
|
461
|
+
// the page description is the page header's lead text
|
|
462
|
+
const item = toJS(store.activeItem);
|
|
463
|
+
this._lead = item && item.description ? item.description : "";
|
|
464
|
+
}),
|
|
465
|
+
);
|
|
466
|
+
this.__primerDisposers.push(
|
|
467
|
+
autorun(() => {
|
|
468
|
+
// close the overlay drawer after navigating on small screens
|
|
469
|
+
toJS(store.activeId);
|
|
470
|
+
if (this._mobile) {
|
|
471
|
+
this.sidebarOpen = false;
|
|
472
|
+
}
|
|
473
|
+
}),
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
disconnectedCallback() {
|
|
478
|
+
if (this.__mq) {
|
|
479
|
+
this.__mq.removeEventListener("change", this.__mqHandler);
|
|
480
|
+
}
|
|
481
|
+
this.__primerDisposers.forEach((dispose) => dispose());
|
|
482
|
+
this.__primerDisposers = [];
|
|
483
|
+
super.disconnectedCallback();
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
toggleSidebar() {
|
|
487
|
+
this.sidebarOpen = !this.sidebarOpen;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
toggleDarkMode() {
|
|
491
|
+
store.darkMode = !store.darkMode;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
globalThis.customElements.define(PrimerTheme.tag, PrimerTheme);
|
|
495
|
+
export { PrimerTheme };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
globalThis.process = globalThis.process || {
|
|
2
|
+
env: {
|
|
3
|
+
NODE_ENV: "development",
|
|
4
|
+
},
|
|
5
|
+
};
|
|
6
|
+
import { fixture, expect, html } from "@open-wc/testing";
|
|
7
|
+
import { PrimerTheme } from "../primer-theme.js";
|
|
8
|
+
import { DesignSystemManager } from "@haxtheweb/d-d-d/lib/DesignSystemManager.js";
|
|
9
|
+
import { PRIMER_SYSTEM } from "../lib/PrimerDesignSystem.js";
|
|
10
|
+
|
|
11
|
+
describe("primer-theme", () => {
|
|
12
|
+
let element;
|
|
13
|
+
beforeEach(async () => {
|
|
14
|
+
element = await fixture(html`<primer-theme></primer-theme>`);
|
|
15
|
+
await element.updateComplete;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("is defined with its tag", () => {
|
|
19
|
+
expect(PrimerTheme.tag).to.equal("primer-theme");
|
|
20
|
+
expect(globalThis.customElements.get("primer-theme")).to.equal(PrimerTheme);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("keeps the HAX content contract and a skip link", () => {
|
|
24
|
+
const root = element.shadowRoot;
|
|
25
|
+
expect(root.querySelector("a.skip-link[href='#contentcontainer']")).to
|
|
26
|
+
.exist;
|
|
27
|
+
expect(root.querySelector("#contentcontainer > #slot > slot")).to.exist;
|
|
28
|
+
expect(root.querySelector("nav site-menu")).to.exist;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("makes Primer the active design system as a DDD dialect", () => {
|
|
32
|
+
expect(DesignSystemManager.active).to.equal(PRIMER_SYSTEM);
|
|
33
|
+
expect(DesignSystemManager.systems[PRIMER_SYSTEM].extends).to.equal("ddd");
|
|
34
|
+
expect(DesignSystemManager.isActiveCompatible("ddd")).to.be.true;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("points DDD tokens at Primer tokens", () => {
|
|
38
|
+
const styles = globalThis.getComputedStyle(element);
|
|
39
|
+
expect(
|
|
40
|
+
styles.getPropertyValue("--ddd-theme-default-beaverBlue").trim(),
|
|
41
|
+
).to.equal("#0969da");
|
|
42
|
+
expect(styles.getPropertyValue("--ddd-font-primary")).to.contain(
|
|
43
|
+
"Mona Sans",
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("keeps DDD structure and rounds the corners", () => {
|
|
48
|
+
const styles = globalThis.getComputedStyle(element);
|
|
49
|
+
expect(styles.getPropertyValue("--ddd-spacing-4").trim()).to.equal("16px");
|
|
50
|
+
expect(styles.getPropertyValue("--ddd-radius-sm").trim()).to.equal("6px");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("toggles the sidebar with the masthead button", async () => {
|
|
54
|
+
const before = element.sidebarOpen;
|
|
55
|
+
element.shadowRoot.querySelector(".header simple-icon-button-lite").click();
|
|
56
|
+
await element.updateComplete;
|
|
57
|
+
expect(element.sidebarOpen).to.equal(!before);
|
|
58
|
+
const toggle = element.shadowRoot.querySelector(
|
|
59
|
+
".header simple-icon-button-lite",
|
|
60
|
+
);
|
|
61
|
+
expect(toggle.getAttribute("aria-expanded")).to.equal(
|
|
62
|
+
element.sidebarOpen ? "true" : "false",
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("passes the a11y audit", async () => {
|
|
67
|
+
// with no site loaded the site title is empty, and axe can't follow a
|
|
68
|
+
// skip link into the shadow root; both are covered in a loaded site
|
|
69
|
+
await expect(element).shadowDom.to.be.accessible({
|
|
70
|
+
ignoredRules: ["skip-link", "empty-heading"],
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|