@portosaur/theme 0.1.4 → 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 (31) hide show
  1. package/package.json +10 -3
  2. package/src/plugins/theme.mjs +2 -0
  3. package/theme/DocCategoryGeneratedIndexPage/index.jsx +4 -10
  4. package/theme/MDXComponents.jsx +1 -1
  5. package/theme/Root.jsx +1 -1
  6. package/theme/components/AboutSection/index.jsx +89 -249
  7. package/theme/components/ContactSection/index.jsx +72 -153
  8. package/theme/components/ExperienceSection/index.jsx +35 -106
  9. package/theme/components/HeroSection/index.jsx +64 -186
  10. package/theme/components/NavArrow/index.jsx +38 -55
  11. package/theme/components/NoteIndex/index.jsx +50 -116
  12. package/theme/components/Preview/components/FeedbackStates.jsx +45 -190
  13. package/theme/components/Preview/components/FileTabs.jsx +17 -24
  14. package/theme/components/Preview/components/PreviewContent.jsx +37 -62
  15. package/theme/components/Preview/components/PreviewHeader.jsx +146 -380
  16. package/theme/components/Preview/components/Triggers/Pv.jsx +50 -78
  17. package/theme/components/Preview/components/Triggers/SrcPv.jsx +16 -47
  18. package/theme/components/Preview/components/Triggers/index.jsx +2 -2
  19. package/theme/components/Preview/components/ViewerWindow.jsx +160 -268
  20. package/theme/components/Preview/index.jsx +3 -3
  21. package/theme/components/Preview/renderers/CodeRenderer.jsx +81 -109
  22. package/theme/components/Preview/renderers/ImageRenderer.jsx +30 -67
  23. package/theme/components/Preview/renderers/PdfRenderer.jsx +31 -52
  24. package/theme/components/Preview/renderers/WebRenderer.jsx +18 -32
  25. package/theme/components/Preview/state/index.jsx +46 -30
  26. package/theme/components/ProjectsSection/index.jsx +278 -573
  27. package/theme/components/SocialLinks/index.jsx +43 -55
  28. package/theme/components/Tooltip/index.jsx +28 -39
  29. package/theme/pages/index.jsx +23 -87
  30. package/theme/pages/notes.jsx +26 -104
  31. package/theme/pages/tasks.jsx +220 -903
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useMemo } from "react";
2
2
  import { useLocation } from "@docusaurus/router";
3
- import { usePreview } from "../../state";
4
- import Tooltip from "../../../Tooltip";
3
+ import { usePreview } from "../../state/index.jsx";
4
+ import Tooltip from "../../../Tooltip/index.jsx";
5
5
  import {
6
6
  generatePvSlug,
7
7
  generatePvHash,
@@ -9,6 +9,7 @@ import {
9
9
  classify,
10
10
  } from "../../utils";
11
11
  import styles from "../../styles.module.css";
12
+
12
13
  export function normalizeSources({
13
14
  href,
14
15
  path,
@@ -24,6 +25,7 @@ export function normalizeSources({
24
25
  : href || path
25
26
  ? [{ path: (href || path).trim(), label: null, desc }]
26
27
  : [];
28
+
27
29
  return rawSources.map((src) => {
28
30
  const sPath = (src.path || src.href || "").trim();
29
31
  const sDesc = src.desc || "";
@@ -35,6 +37,7 @@ export function normalizeSources({
35
37
  let urlLabel = "";
36
38
  let domain = "";
37
39
  let type = "text";
40
+
38
41
  if (sPath) {
39
42
  type = classify(sPath);
40
43
  const cleanPath = sPath.split(/[?#]/)[0].toLowerCase();
@@ -48,9 +51,11 @@ export function normalizeSources({
48
51
  }
49
52
  } catch (e) {}
50
53
  }
54
+
51
55
  const source = domain || urlLabel || "Local";
52
56
  const displayLabel = label || source;
53
57
  const tooltip = sDesc || null;
58
+
54
59
  return {
55
60
  path: sPath,
56
61
  label: displayLabel,
@@ -63,6 +68,7 @@ export function normalizeSources({
63
68
  };
64
69
  });
65
70
  }
71
+
66
72
  export default function Pv(props) {
67
73
  const {
68
74
  children,
@@ -74,34 +80,24 @@ export default function Pv(props) {
74
80
  modeSwitch = true,
75
81
  underline = true,
76
82
  } = props;
83
+
77
84
  const hasSingleSource = !!(props.href || props.path);
78
85
  const hasMultiSource = !!(overrideSources && overrideSources.length > 0);
86
+
79
87
  if (!hasSingleSource && !hasMultiSource) {
80
88
  console.error(
81
89
  "<Pv> component requires either 'href', 'path', or 'sources' prop.",
82
90
  );
83
- return jsxDEV_7x81h0kn(
84
- "span",
85
- { style: { color: "red" }, children: "[Preview Error: Missing href]" },
86
- undefined,
87
- false,
88
- undefined,
89
- this,
90
- );
91
+ return <span style={{ color: "red" }}>[Preview Error: Missing href]</span>;
91
92
  }
93
+
92
94
  if (hasSingleSource && hasMultiSource) {
93
95
  console.error(
94
96
  "<Pv> component cannot accept both 'href' and 'sources'. Choose one.",
95
97
  );
96
- return jsxDEV_7x81h0kn(
97
- "span",
98
- { style: { color: "red" }, children: "[Preview Error: Conflict]" },
99
- undefined,
100
- false,
101
- undefined,
102
- this,
103
- );
98
+ return <span style={{ color: "red" }}>[Preview Error: Conflict]</span>;
104
99
  }
100
+
105
101
  const {
106
102
  isOpen,
107
103
  mode: currentMode,
@@ -111,11 +107,13 @@ export default function Pv(props) {
111
107
  closePreview,
112
108
  setMode,
113
109
  } = usePreview();
110
+
114
111
  const location = useLocation();
115
112
  const srcList = useMemo(
116
113
  () => overrideSources || normalizeSources(props),
117
114
  [props, overrideSources, title],
118
115
  );
116
+
119
117
  const baseSlug = useMemo(() => {
120
118
  if (manualId) return generatePvSlug(manualId);
121
119
  if (title) return generatePvSlug(title);
@@ -132,6 +130,7 @@ export default function Pv(props) {
132
130
  if (childrenText) return generatePvSlug(childrenText);
133
131
  return "preview";
134
132
  }, [manualId, title, props.href, props.path, srcList, activeIdx, children]);
133
+
135
134
  useEffect(() => {
136
135
  const timer = setTimeout(() => {
137
136
  const parsed = parsePvHash(window.location.hash);
@@ -159,20 +158,17 @@ export default function Pv(props) {
159
158
  activeIdx,
160
159
  modeSwitch,
161
160
  ]);
162
- if (srcList.length === 0)
163
- return jsxDEV_7x81h0kn(
164
- "span",
165
- { children },
166
- undefined,
167
- false,
168
- undefined,
169
- this,
170
- );
161
+
162
+ if (srcList.length === 0) {
163
+ return <span>{children}</span>;
164
+ }
165
+
171
166
  const isCurrentlyActive =
172
167
  isOpen &&
173
168
  activeSources.length === srcList.length &&
174
169
  activeSources[activeIdx]?.path === srcList[activeIdx]?.path &&
175
170
  activeIndex === activeIdx;
171
+
176
172
  const handleClick = () => {
177
173
  if (isCurrentlyActive) {
178
174
  closePreview();
@@ -188,66 +184,42 @@ export default function Pv(props) {
188
184
  );
189
185
  }
190
186
  };
187
+
191
188
  const targetHash = generatePvHash(baseSlug, mode);
192
- const trigger = jsxDEV_7x81h0kn(
193
- "a",
194
- {
195
- href: `#${targetHash}`,
196
- className: `${styles.previewTrigger} ${isCurrentlyActive ? styles.activeTrigger : ""} ${!underline ? styles.noUnderline : ""}`,
197
- onClick: (e) => {
189
+
190
+ const trigger = (
191
+ <a
192
+ href={`#${targetHash}`}
193
+ className={`${styles.previewTrigger} ${isCurrentlyActive ? styles.activeTrigger : ""} ${!underline ? styles.noUnderline : ""}`}
194
+ onClick={(e) => {
198
195
  e.preventDefault();
199
196
  handleClick();
200
- },
201
- role: "button",
202
- tabIndex: 0,
203
- onKeyDown: (e) => {
197
+ }}
198
+ role="button"
199
+ tabIndex={0}
200
+ onKeyDown={(e) => {
204
201
  if (e.key === "Enter") {
205
202
  e.preventDefault();
206
203
  handleClick();
207
204
  }
208
- },
209
- children: children || srcList[activeIdx]?.label,
210
- },
211
- undefined,
212
- false,
213
- undefined,
214
- this,
205
+ }}
206
+ >
207
+ {children || srcList[activeIdx]?.label}
208
+ </a>
215
209
  );
210
+
216
211
  const hasTooltip = !!srcList[activeIdx]?.tooltip;
217
- if (!hasTooltip) {
218
- return jsxDEV_7x81h0kn(
219
- "span",
220
- { className: styles.previewContainer, children: trigger },
221
- undefined,
222
- false,
223
- undefined,
224
- this,
225
- );
226
- }
227
212
  const tooltipMsg = srcList[activeIdx]?.tooltip;
228
- return jsxDEV_7x81h0kn(
229
- "span",
230
- {
231
- className: styles.previewContainer,
232
- children: tooltipMsg
233
- ? jsxDEV_7x81h0kn(
234
- Tooltip,
235
- {
236
- msg: tooltipMsg,
237
- position: "top",
238
- underline: false,
239
- children: trigger,
240
- },
241
- undefined,
242
- false,
243
- undefined,
244
- this,
245
- )
246
- : trigger,
247
- },
248
- undefined,
249
- false,
250
- undefined,
251
- this,
213
+
214
+ return (
215
+ <span className={styles.previewContainer}>
216
+ {hasTooltip && tooltipMsg ? (
217
+ <Tooltip msg={tooltipMsg} position="top" underline={false}>
218
+ {trigger}
219
+ </Tooltip>
220
+ ) : (
221
+ trigger
222
+ )}
223
+ </span>
252
224
  );
253
225
  }
@@ -1,55 +1,24 @@
1
1
  import React, { useMemo } from "react";
2
- import Pv, { normalizeSources } from "./Pv";
2
+ import Pv, { normalizeSources } from "./Pv.jsx";
3
3
  import styles from "../../styles.module.css";
4
+
4
5
  export default function SrcPv(props) {
5
6
  const { prefixText = "Source file: " } = props;
6
7
  const srcList = useMemo(() => normalizeSources(props), [props]);
8
+
7
9
  if (srcList.length === 0) return null;
8
- return jsxDEV_7x81h0kn(
9
- "div",
10
- {
11
- className: styles.sourceFooter,
12
- children: [
13
- jsxDEV_7x81h0kn(
14
- "span",
15
- { className: styles.sourceFooterLabel, children: prefixText },
16
- undefined,
17
- false,
18
- undefined,
19
- this,
20
- ),
21
- srcList.map((src, idx) =>
22
- jsxDEV_7x81h0kn(
23
- React.Fragment,
24
- {
25
- children: [
26
- jsxDEV_7x81h0kn(
27
- Pv,
28
- {
29
- ...props,
30
- sources: srcList,
31
- activeIdx: idx,
32
- children: src.label,
33
- },
34
- undefined,
35
- false,
36
- undefined,
37
- this,
38
- ),
39
- idx < srcList.length - 1 ? ", " : "",
40
- ],
41
- },
42
- idx,
43
- true,
44
- undefined,
45
- this,
46
- ),
47
- ),
48
- ],
49
- },
50
- undefined,
51
- true,
52
- undefined,
53
- this,
10
+
11
+ return (
12
+ <div className={styles.sourceFooter}>
13
+ <span className={styles.sourceFooterLabel}>{prefixText}</span>
14
+ {srcList.map((src, idx) => (
15
+ <React.Fragment key={idx}>
16
+ <Pv {...props} sources={srcList} activeIdx={idx}>
17
+ {src.label}
18
+ </Pv>
19
+ {idx < srcList.length - 1 ? ", " : ""}
20
+ </React.Fragment>
21
+ ))}
22
+ </div>
54
23
  );
55
24
  }
@@ -1,2 +1,2 @@
1
- export { default as Pv } from "./Pv";
2
- export { default as SrcPv } from "./SrcPv";
1
+ export { default as Pv } from "./Pv.jsx";
2
+ export { default as SrcPv } from "./SrcPv.jsx";