@dino-ovum/theme 0.1.0 → 0.2.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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/src/app/components/ErrorPageContent.jsx +36 -0
  3. package/src/app/components/LibraryLayout.jsx +2 -0
  4. package/src/app/components/NotFoundContent.jsx +24 -0
  5. package/src/app/components/StatusPage.jsx +54 -0
  6. package/src/app/components/comments/CommentButton.jsx +19 -0
  7. package/src/app/components/comments/CommentDrawer.jsx +101 -0
  8. package/src/app/components/comments/CommentPopover.jsx +89 -0
  9. package/src/app/components/comments/DocumentComments.jsx +174 -0
  10. package/src/app/components/comments/HighlightLayer.jsx +30 -0
  11. package/src/app/components/navigation/ColorModeToggle.jsx +3 -34
  12. package/src/app/components/navigation/CommentsToggle.jsx +49 -0
  13. package/src/app/components/navigation/LanguageDropdown.jsx +14 -20
  14. package/src/app/components/navigation/MoreMenu.jsx +162 -0
  15. package/src/app/components/navigation/RecentUpdatesLink.jsx +3 -1
  16. package/src/app/hooks/useColorModeSwitch.js +42 -0
  17. package/src/app/hooks/useHighlightBoxes.js +89 -0
  18. package/src/app/hooks/useLocaleLinks.js +20 -0
  19. package/src/app/hooks/useTextSelection.js +56 -0
  20. package/src/app/logic/comment-boxes.js +87 -0
  21. package/src/app/logic/comment-list.js +22 -0
  22. package/src/app/providers/AppProviders.jsx +6 -1
  23. package/src/app/providers/CommentDrawer.jsx +30 -0
  24. package/src/app/styles/components/StatusPage.module.scss +55 -0
  25. package/src/app/styles/components/comments/CommentDrawer.module.scss +189 -0
  26. package/src/app/styles/components/comments/DocumentComments.module.scss +91 -0
  27. package/src/app/styles/components/navigation/MoreMenu.module.scss +41 -0
  28. package/src/app/styles/components/navigation/NavigationControls.module.scss +37 -0
  29. package/src/app/styles/theme/navigation.scss +10 -0
  30. package/src/app/styles/tokens/colors.css +10 -0
  31. package/src/app/styles/tokens/layout.css +1 -0
  32. package/src/index.js +4 -0
  33. package/src/theme/DocItem/Content/index.jsx +17 -0
  34. package/src/theme/ErrorPageContent.jsx +1 -0
  35. package/src/theme/NavbarItem/ComponentTypes.jsx +4 -0
  36. package/src/theme/NotFound/Content/index.jsx +1 -0
  37. package/src/translations/ja.json +54 -0
  38. package/src/translations/ko.json +54 -0
@@ -0,0 +1,189 @@
1
+ @use '../../tokens/breakpoints' as breakpoints;
2
+
3
+ // Narrow screens: the drawer slides over the document from the right edge.
4
+ .backdrop {
5
+ position: fixed;
6
+ inset: var(--ifm-navbar-height) 0 0;
7
+ z-index: var(--ifm-z-index-fixed);
8
+ visibility: hidden;
9
+ background: var(--library-backdrop-bg);
10
+ opacity: 0;
11
+ transition:
12
+ opacity var(--library-motion-duration) var(--library-motion-easing),
13
+ visibility var(--library-motion-duration);
14
+ }
15
+
16
+ .backdrop[data-open='true'] {
17
+ visibility: visible;
18
+ opacity: 1;
19
+ }
20
+
21
+ .drawer {
22
+ position: fixed;
23
+ top: var(--ifm-navbar-height);
24
+ right: 0;
25
+ bottom: 0;
26
+ z-index: var(--ifm-z-index-fixed);
27
+ width: min(var(--library-comment-drawer-width), 85vw);
28
+ border-left: 1px solid var(--ifm-color-emphasis-300);
29
+ background: var(--ifm-background-color);
30
+ box-shadow: var(--ifm-global-shadow-md);
31
+ transition:
32
+ transform var(--library-motion-duration) var(--library-motion-easing),
33
+ visibility var(--library-motion-duration);
34
+ }
35
+
36
+ .drawer[data-open='false'] {
37
+ visibility: hidden;
38
+ transform: translateX(100%);
39
+ }
40
+
41
+ .panel {
42
+ display: flex;
43
+ flex-direction: column;
44
+ gap: 0.75rem;
45
+ height: 100%;
46
+ padding: 1rem;
47
+ overflow-y: auto;
48
+ overscroll-behavior: contain;
49
+ }
50
+
51
+ // Wide screens: the drawer takes its own column, the way the library
52
+ // navigation does on the left.
53
+ @media (width >= breakpoints.$desktop) {
54
+ .backdrop {
55
+ display: none;
56
+ }
57
+
58
+ .drawer {
59
+ position: sticky;
60
+ z-index: auto;
61
+ flex-shrink: 0;
62
+ width: var(--library-comment-drawer-width);
63
+ height: calc(var(--library-viewport-height) - var(--ifm-navbar-height));
64
+ overflow: hidden;
65
+ box-shadow: none;
66
+ transition:
67
+ width var(--library-motion-duration) var(--library-motion-easing),
68
+ visibility var(--library-motion-duration);
69
+ }
70
+
71
+ .panel {
72
+ width: var(--library-comment-drawer-width);
73
+ transition:
74
+ transform var(--library-motion-duration) var(--library-motion-easing),
75
+ opacity var(--library-motion-duration) var(--library-motion-easing);
76
+ }
77
+
78
+ // Hidden while closed at every width, so crossing the breakpoint does not
79
+ // show the closed drawer sliding between its two layouts.
80
+ .drawer[data-open='false'] {
81
+ width: 0;
82
+ border-left-width: 0;
83
+ transform: none;
84
+
85
+ .panel {
86
+ opacity: 0;
87
+ transform: translateX(100%);
88
+ }
89
+ }
90
+ }
91
+
92
+ .header {
93
+ display: flex;
94
+ align-items: center;
95
+ justify-content: space-between;
96
+ gap: 0.5rem;
97
+ }
98
+
99
+ .title {
100
+ margin: 0;
101
+ font-size: 1rem;
102
+ }
103
+
104
+ .count {
105
+ margin-left: 0.375rem;
106
+ color: var(--ifm-color-emphasis-700);
107
+ font-weight: 400;
108
+ }
109
+
110
+ .close {
111
+ display: inline-flex;
112
+ flex-shrink: 0;
113
+ align-items: center;
114
+ justify-content: center;
115
+ width: 32px;
116
+ height: 32px;
117
+ border-radius: 6px;
118
+ color: var(--ifm-color-emphasis-800);
119
+
120
+ &:hover {
121
+ background: var(--ifm-color-emphasis-200);
122
+ }
123
+
124
+ &:focus-visible {
125
+ outline: 2px solid var(--ifm-color-primary);
126
+ outline-offset: -2px;
127
+ }
128
+ }
129
+
130
+ .list {
131
+ display: flex;
132
+ flex-direction: column;
133
+ gap: 0.5rem;
134
+ margin: 0;
135
+ padding: 0;
136
+ list-style: none;
137
+ }
138
+
139
+ .item {
140
+ display: flex;
141
+ flex-direction: column;
142
+ gap: 0.25rem;
143
+ width: 100%;
144
+ padding: 0.625rem 0.75rem;
145
+ border: 1px solid var(--ifm-color-emphasis-300);
146
+ border-radius: var(--ifm-global-radius);
147
+ background: var(--ifm-background-surface-color);
148
+ color: inherit;
149
+ font: inherit;
150
+ text-align: start;
151
+ cursor: pointer;
152
+
153
+ &:hover {
154
+ border-color: var(--ifm-color-primary);
155
+ }
156
+
157
+ &:focus-visible {
158
+ outline: 2px solid var(--ifm-color-primary);
159
+ outline-offset: 2px;
160
+ }
161
+ }
162
+
163
+ // The highlighted text, on one line, marked like the highlight itself.
164
+ .quote {
165
+ overflow: hidden;
166
+ padding-left: 0.5rem;
167
+ border-left: 3px solid var(--library-comment-highlight-active-bg);
168
+ color: var(--ifm-color-emphasis-700);
169
+ font-size: 0.8125rem;
170
+ text-overflow: ellipsis;
171
+ white-space: nowrap;
172
+ }
173
+
174
+ .text {
175
+ font-size: 0.9375rem;
176
+ white-space: pre-wrap;
177
+ overflow-wrap: anywhere;
178
+ }
179
+
180
+ .empty,
181
+ .notice {
182
+ margin: 0;
183
+ color: var(--ifm-color-emphasis-700);
184
+ font-size: 0.8125rem;
185
+ }
186
+
187
+ .notice {
188
+ margin-top: auto;
189
+ }
@@ -0,0 +1,91 @@
1
+ // Highlights and controls are positioned inside .root, so they scroll with the text.
2
+ .root {
3
+ position: relative;
4
+ }
5
+
6
+ .layer {
7
+ position: absolute;
8
+ inset: 0;
9
+ z-index: 1;
10
+ pointer-events: none;
11
+ }
12
+
13
+ .highlight {
14
+ position: absolute;
15
+ border-radius: 2px;
16
+ background: var(--library-comment-highlight-bg);
17
+ mix-blend-mode: var(--library-comment-highlight-blend);
18
+ }
19
+
20
+ .highlight-active {
21
+ background: var(--library-comment-highlight-active-bg);
22
+ }
23
+
24
+ .highlight-draft {
25
+ background: var(--library-comment-draft-bg);
26
+ }
27
+
28
+ // Keep the controls inside the document column while following the selection end.
29
+ .add-button,
30
+ .popover {
31
+ position: absolute;
32
+ top: calc(var(--comment-anchor-y) + 0.5rem);
33
+ z-index: var(--ifm-z-index-dropdown);
34
+ }
35
+
36
+ .add-button {
37
+ left: clamp(0rem, calc(var(--comment-anchor-x) - 5rem), calc(100% - 10rem));
38
+ max-width: 10rem;
39
+ white-space: nowrap;
40
+ box-shadow: var(--ifm-global-shadow-md);
41
+ }
42
+
43
+ .popover {
44
+ left: clamp(0rem, calc(var(--comment-anchor-x) - 10rem), calc(100% - min(20rem, 100%)));
45
+ width: min(20rem, 100%);
46
+ padding: 0.75rem;
47
+ border: 1px solid var(--ifm-color-emphasis-300);
48
+ border-radius: var(--ifm-global-radius);
49
+ background: var(--ifm-background-surface-color);
50
+ box-shadow: var(--ifm-global-shadow-md);
51
+ }
52
+
53
+ .input {
54
+ display: block;
55
+ width: 100%;
56
+ min-height: 5rem;
57
+ padding: 0.5rem;
58
+ border: 1px solid var(--ifm-color-emphasis-300);
59
+ border-radius: var(--ifm-global-radius);
60
+ background: var(--ifm-background-color);
61
+ color: inherit;
62
+ font: inherit;
63
+ resize: vertical;
64
+ }
65
+
66
+ .text {
67
+ margin: 0;
68
+ white-space: pre-wrap;
69
+ overflow-wrap: anywhere;
70
+ }
71
+
72
+ .notice {
73
+ margin: 0.5rem 0 0;
74
+ color: var(--ifm-color-emphasis-700);
75
+ font-size: 0.8125rem;
76
+ }
77
+
78
+ .actions {
79
+ display: flex;
80
+ justify-content: flex-end;
81
+ gap: 0.5rem;
82
+ margin-top: 0.75rem;
83
+ }
84
+
85
+ // Touch targets need more room than mouse targets.
86
+ @media (pointer: coarse) {
87
+ .add-button,
88
+ .actions button {
89
+ min-height: 44px;
90
+ }
91
+ }
@@ -0,0 +1,41 @@
1
+ .dropdown {
2
+ position: relative;
3
+ flex-shrink: 0;
4
+ }
5
+
6
+ .panel {
7
+ position: absolute;
8
+ z-index: 1;
9
+ top: calc(100% + 0.25rem);
10
+ right: 0;
11
+ min-width: 13rem;
12
+ padding: 0.375rem;
13
+ border: 1px solid var(--ifm-color-emphasis-300);
14
+ border-radius: 8px;
15
+ background: var(--ifm-background-surface-color);
16
+ box-shadow: var(--ifm-global-shadow-lw);
17
+ }
18
+
19
+ .action {
20
+ width: 100%;
21
+ font: inherit;
22
+ text-align: start;
23
+ }
24
+
25
+ .heading {
26
+ margin: 0.375rem 0 0;
27
+ padding: 0.5rem 0.75rem 0.25rem;
28
+ border-top: 1px solid var(--ifm-color-emphasis-300);
29
+ color: var(--ifm-color-emphasis-700);
30
+ font-size: 0.75rem;
31
+ font-weight: 600;
32
+ }
33
+
34
+ .language {
35
+ justify-content: space-between;
36
+
37
+ &[aria-current] {
38
+ color: var(--ifm-color-primary);
39
+ font-weight: 600;
40
+ }
41
+ }
@@ -42,6 +42,26 @@
42
42
  }
43
43
  }
44
44
 
45
+ .comments-toggle[aria-expanded='true']::before {
46
+ background: var(--ifm-color-emphasis-200);
47
+ }
48
+
49
+ .badge {
50
+ position: absolute;
51
+ top: 4px;
52
+ right: 2px;
53
+ min-width: 1.125rem;
54
+ height: 1.125rem;
55
+ padding: 0 0.25rem;
56
+ border-radius: 999px;
57
+ background: var(--ifm-color-primary);
58
+ color: var(--library-on-accent);
59
+ font-size: 0.6875rem;
60
+ font-weight: 700;
61
+ line-height: 1.125rem;
62
+ text-align: center;
63
+ }
64
+
45
65
  .menu-link {
46
66
  gap: 0.5rem;
47
67
  }
@@ -68,3 +88,20 @@
68
88
  position: static;
69
89
  }
70
90
  }
91
+
92
+ // Narrow screens: recent updates, the color mode, and the languages move
93
+ // into the More menu so the top bar stays on one line.
94
+ .narrow-only {
95
+ display: none;
96
+ }
97
+
98
+ @media (width <= breakpoints.$mobile) {
99
+ .narrow-only {
100
+ display: block;
101
+ }
102
+
103
+ .wide-only,
104
+ :global(.theme-layout-navbar-right) .theme-toggle {
105
+ display: none;
106
+ }
107
+ }
@@ -40,6 +40,16 @@
40
40
  font-size: var(--library-font-size-brand-compact);
41
41
  }
42
42
 
43
+ // Infima lets the right group wrap below the bar. Keep one line and let the
44
+ // title shorten with an ellipsis (text--truncate) instead.
45
+ .navbar__inner {
46
+ flex-wrap: nowrap;
47
+ }
48
+
49
+ .navbar__brand {
50
+ min-width: 0;
51
+ }
52
+
43
53
  .theme-layout-navbar-left {
44
54
  flex: 1 1 auto;
45
55
  min-width: 0;
@@ -28,6 +28,11 @@
28
28
  --library-badge-4-fg: #9f1239;
29
29
  --library-badge-5-bg: #e2e8f0;
30
30
  --library-badge-5-fg: #334155;
31
+ --library-comment-highlight-bg: rgb(255 214 10 / 45%);
32
+ --library-comment-highlight-active-bg: rgb(255 179 0 / 60%);
33
+ --library-comment-draft-bg: rgb(46 133 85 / 25%);
34
+ --library-comment-highlight-blend: multiply;
35
+ --library-backdrop-bg: rgb(0 0 0 / 40%);
31
36
  }
32
37
 
33
38
  [data-theme='dark'] {
@@ -59,4 +64,9 @@
59
64
  --library-badge-4-fg: #fecdd3;
60
65
  --library-badge-5-bg: #334155;
61
66
  --library-badge-5-fg: #e2e8f0;
67
+ --library-comment-highlight-bg: rgb(255 214 10 / 25%);
68
+ --library-comment-highlight-active-bg: rgb(255 179 0 / 40%);
69
+ --library-comment-draft-bg: rgb(37 194 160 / 25%);
70
+ --library-comment-highlight-blend: normal;
71
+ --library-backdrop-bg: rgb(0 0 0 / 60%);
62
72
  }
@@ -1,5 +1,6 @@
1
1
  :root {
2
2
  --library-sidebar-width: 300px;
3
+ --library-comment-drawer-width: 300px;
3
4
  --library-content-gutter: clamp(1rem, 6vw, 6rem);
4
5
  --library-content-padding-top: 1rem;
5
6
  --library-content-padding-bottom: 2rem;
package/src/index.js CHANGED
@@ -22,6 +22,10 @@ export default function dinoTheme(context, options = {}) {
22
22
  },
23
23
  };
24
24
  },
25
+ // Client components read the switches with usePluginData('dino-ovum-theme').
26
+ async contentLoaded({actions}) {
27
+ actions.setGlobalData({comments: options.comments === true});
28
+ },
25
29
  getThemePath() {
26
30
  return fileURLToPath(new URL('./theme', import.meta.url));
27
31
  },
@@ -0,0 +1,17 @@
1
+ import {useLocation} from '@docusaurus/router';
2
+ import {usePluginData} from '@docusaurus/useGlobalData';
3
+ import OriginalDocItemContent from '@theme-init/DocItem/Content';
4
+ import DocumentComments from '../../../app/components/comments/DocumentComments.jsx';
5
+
6
+ // The `comments` option adds temporary comments to the document body only.
7
+ export default function DocItemContent(props) {
8
+ const {comments} = usePluginData('dino-ovum-theme') ?? {};
9
+ const {pathname} = useLocation();
10
+ if (!comments) return <OriginalDocItemContent {...props} />;
11
+ return (
12
+ // A new document starts without comments.
13
+ <DocumentComments key={pathname}>
14
+ <OriginalDocItemContent {...props} />
15
+ </DocumentComments>
16
+ );
17
+ }
@@ -0,0 +1 @@
1
+ export {default} from '../app/components/ErrorPageContent.jsx';
@@ -2,10 +2,14 @@ import ComponentTypes from '@theme-init/NavbarItem/ComponentTypes';
2
2
  import SidebarToggle from '../../app/components/navigation/SidebarToggle.jsx';
3
3
  import RecentUpdatesLink from '../../app/components/navigation/RecentUpdatesLink.jsx';
4
4
  import LanguageDropdown from '../../app/components/navigation/LanguageDropdown.jsx';
5
+ import CommentsToggle from '../../app/components/navigation/CommentsToggle.jsx';
6
+ import MoreMenu from '../../app/components/navigation/MoreMenu.jsx';
5
7
 
6
8
  export default {
7
9
  ...ComponentTypes,
8
10
  'custom-sidebarToggle': SidebarToggle,
11
+ 'custom-comments': CommentsToggle,
9
12
  'custom-recentUpdates': RecentUpdatesLink,
10
13
  'custom-languageDropdown': LanguageDropdown,
14
+ 'custom-moreMenu': MoreMenu,
11
15
  };
@@ -0,0 +1 @@
1
+ export {default} from '../../../app/components/NotFoundContent.jsx';
@@ -88,5 +88,59 @@
88
88
  },
89
89
  "docnest.updates.empty": {
90
90
  "message": "条件に一致する文書がありません。"
91
+ },
92
+ "docnest.error.title": {
93
+ "message": "エラーが発生しました"
94
+ },
95
+ "docnest.error.description": {
96
+ "message": "ページを表示できませんでした。もう一度試すか、ホームに戻ってください。"
97
+ },
98
+ "docnest.error.retry": {
99
+ "message": "もう一度試す"
100
+ },
101
+ "docnest.error.home": {
102
+ "message": "ホームに戻る"
103
+ },
104
+ "docnest.error.details": {
105
+ "message": "エラーの詳細"
106
+ },
107
+ "docnest.comments.add": {
108
+ "message": "コメントを追加"
109
+ },
110
+ "docnest.comments.label": {
111
+ "message": "コメント"
112
+ },
113
+ "docnest.comments.placeholder": {
114
+ "message": "コメントを入力してください"
115
+ },
116
+ "docnest.comments.notice": {
117
+ "message": "再読み込みするか別の文書に移動すると消えます。"
118
+ },
119
+ "docnest.comments.cancel": {
120
+ "message": "キャンセル"
121
+ },
122
+ "docnest.comments.save": {
123
+ "message": "追加"
124
+ },
125
+ "docnest.comments.delete": {
126
+ "message": "削除"
127
+ },
128
+ "docnest.comments.close": {
129
+ "message": "閉じる"
130
+ },
131
+ "docnest.comments.show": {
132
+ "message": "コメント一覧を開く"
133
+ },
134
+ "docnest.comments.hide": {
135
+ "message": "コメント一覧を閉じる"
136
+ },
137
+ "docnest.comments.title": {
138
+ "message": "このページのコメント"
139
+ },
140
+ "docnest.comments.empty": {
141
+ "message": "本文のテキストを選択するとコメントを追加できます。"
142
+ },
143
+ "docnest.navigation.more": {
144
+ "message": "その他"
91
145
  }
92
146
  }
@@ -88,5 +88,59 @@
88
88
  },
89
89
  "docnest.updates.empty": {
90
90
  "message": "조건에 맞는 문서가 없습니다."
91
+ },
92
+ "docnest.error.title": {
93
+ "message": "오류가 발생했습니다"
94
+ },
95
+ "docnest.error.description": {
96
+ "message": "페이지를 표시하지 못했습니다. 다시 시도하거나 홈으로 돌아가 주세요."
97
+ },
98
+ "docnest.error.retry": {
99
+ "message": "다시 시도"
100
+ },
101
+ "docnest.error.home": {
102
+ "message": "홈으로"
103
+ },
104
+ "docnest.error.details": {
105
+ "message": "오류 상세 정보"
106
+ },
107
+ "docnest.comments.add": {
108
+ "message": "코멘트 달기"
109
+ },
110
+ "docnest.comments.label": {
111
+ "message": "코멘트"
112
+ },
113
+ "docnest.comments.placeholder": {
114
+ "message": "코멘트를 입력하세요"
115
+ },
116
+ "docnest.comments.notice": {
117
+ "message": "새로고침하거나 다른 문서로 이동하면 사라집니다."
118
+ },
119
+ "docnest.comments.cancel": {
120
+ "message": "취소"
121
+ },
122
+ "docnest.comments.save": {
123
+ "message": "추가"
124
+ },
125
+ "docnest.comments.delete": {
126
+ "message": "삭제"
127
+ },
128
+ "docnest.comments.close": {
129
+ "message": "닫기"
130
+ },
131
+ "docnest.comments.show": {
132
+ "message": "코멘트 목록 열기"
133
+ },
134
+ "docnest.comments.hide": {
135
+ "message": "코멘트 목록 닫기"
136
+ },
137
+ "docnest.comments.title": {
138
+ "message": "이 페이지의 코멘트"
139
+ },
140
+ "docnest.comments.empty": {
141
+ "message": "본문의 글을 선택하면 코멘트를 달 수 있습니다."
142
+ },
143
+ "docnest.navigation.more": {
144
+ "message": "더 보기"
91
145
  }
92
146
  }