@portosaur/theme 0.1.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/README.md +13 -0
- package/assets/img/icon-old.png +0 -0
- package/assets/img/icon.png +0 -0
- package/assets/img/project-blank.png +0 -0
- package/assets/img/social-card.jpeg +0 -0
- package/assets/img/svg/icon-blog.svg +2 -0
- package/assets/img/svg/icon-close.svg +3 -0
- package/assets/img/svg/icon-dock.svg +4 -0
- package/assets/img/svg/icon-link.svg +5 -0
- package/assets/img/svg/icon-note.svg +2 -0
- package/assets/img/svg/icon-popup.svg +1 -0
- package/assets/img/svg/icon-save.svg +5 -0
- package/assets/img/svg/icon.svg +240 -0
- package/assets/img/svg/project-blank.svg +140 -0
- package/assets/sample-resume.pdf +0 -0
- package/package.json +41 -0
- package/plugins/README.md +8 -0
- package/src/index.d.ts +11 -0
- package/src/index.mjs +14 -0
- package/src/plugins/theme.mjs +13 -0
- package/theme/DocCategoryGeneratedIndexPage/index.jsx +15 -0
- package/theme/MDXComponents.jsx +19 -0
- package/theme/README.md +9 -0
- package/theme/Root.jsx +11 -0
- package/theme/components/AboutSection/index.jsx +264 -0
- package/theme/components/AboutSection/styles.module.css +309 -0
- package/theme/components/ContactSection/index.jsx +188 -0
- package/theme/components/ContactSection/styles.module.css +343 -0
- package/theme/components/ExperienceSection/index.jsx +119 -0
- package/theme/components/ExperienceSection/styles.module.css +183 -0
- package/theme/components/HeroSection/index.jsx +198 -0
- package/theme/components/HeroSection/styles.module.css +484 -0
- package/theme/components/NavArrow/index.jsx +124 -0
- package/theme/components/NavArrow/styles.module.css +107 -0
- package/theme/components/NoteIndex/index.jsx +182 -0
- package/theme/components/NoteIndex/styles.module.css +167 -0
- package/theme/components/Preview/components/FeedbackStates.jsx +200 -0
- package/theme/components/Preview/components/FileTabs.jsx +41 -0
- package/theme/components/Preview/components/PreviewContent.jsx +104 -0
- package/theme/components/Preview/components/PreviewHeader.jsx +411 -0
- package/theme/components/Preview/components/Triggers/Pv.jsx +253 -0
- package/theme/components/Preview/components/Triggers/SrcPv.jsx +55 -0
- package/theme/components/Preview/components/Triggers/index.jsx +2 -0
- package/theme/components/Preview/components/ViewerWindow.jsx +489 -0
- package/theme/components/Preview/hooks/useAdaptiveSizing.jsx +90 -0
- package/theme/components/Preview/hooks/useDeepLinkHash.jsx +24 -0
- package/theme/components/Preview/hooks/useDockLayout.jsx +86 -0
- package/theme/components/Preview/hooks/useFileFetch.jsx +38 -0
- package/theme/components/Preview/hooks/useTouchZoom.jsx +98 -0
- package/theme/components/Preview/index.jsx +3 -0
- package/theme/components/Preview/renderers/CodeRenderer.jsx +124 -0
- package/theme/components/Preview/renderers/ImageRenderer.jsx +74 -0
- package/theme/components/Preview/renderers/PdfRenderer.jsx +93 -0
- package/theme/components/Preview/renderers/WebRenderer.jsx +59 -0
- package/theme/components/Preview/state/index.jsx +177 -0
- package/theme/components/Preview/styles.module.css +776 -0
- package/theme/components/Preview/utils/index.jsx +62 -0
- package/theme/components/ProjectsSection/index.jsx +790 -0
- package/theme/components/ProjectsSection/styles.module.css +900 -0
- package/theme/components/SocialLinks/index.jsx +115 -0
- package/theme/components/SocialLinks/styles.module.css +57 -0
- package/theme/components/Tooltip/index.jsx +104 -0
- package/theme/components/Tooltip/styles.module.css +168 -0
- package/theme/config/iconMappings.jsx +427 -0
- package/theme/config/prism.jsx +72 -0
- package/theme/config/sidebar.jsx +11 -0
- package/theme/css/bootstrap.css +5 -0
- package/theme/css/catppuccin.css +618 -0
- package/theme/css/custom.css +253 -0
- package/theme/css/tasks.css +874 -0
- package/theme/hooks/useScrollReveal.jsx +20 -0
- package/theme/pages/index.jsx +104 -0
- package/theme/pages/notes.jsx +131 -0
- package/theme/pages/tasks.jsx +989 -0
- package/theme/utils/HashNavigation.jsx +185 -0
- package/theme/utils/updateTitle.jsx +65 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
useReducer,
|
|
5
|
+
useCallback,
|
|
6
|
+
ReactNode,
|
|
7
|
+
} from "react";
|
|
8
|
+
const PreviewContext = createContext(null);
|
|
9
|
+
const DEFAULT_SIZE = { width: 720, height: 400 };
|
|
10
|
+
const DEFAULT_DOCK_PERCENTAGE = 0.42;
|
|
11
|
+
function getInitialState() {
|
|
12
|
+
if (typeof window === "undefined") {
|
|
13
|
+
return {
|
|
14
|
+
isOpen: false,
|
|
15
|
+
mode: "popup",
|
|
16
|
+
dockWidth: 420,
|
|
17
|
+
peekHeight: 400,
|
|
18
|
+
sources: [],
|
|
19
|
+
activeIndex: 0,
|
|
20
|
+
baseSlug: null,
|
|
21
|
+
modeSwitch: true,
|
|
22
|
+
floatingState: { ...DEFAULT_SIZE, x: null, y: null },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
let defaultDockWidth = Math.floor(
|
|
26
|
+
window.innerWidth * DEFAULT_DOCK_PERCENTAGE,
|
|
27
|
+
);
|
|
28
|
+
defaultDockWidth = Math.max(
|
|
29
|
+
380,
|
|
30
|
+
Math.min(defaultDockWidth, window.innerWidth * 0.8),
|
|
31
|
+
);
|
|
32
|
+
return {
|
|
33
|
+
isOpen: false,
|
|
34
|
+
mode: "popup",
|
|
35
|
+
dockWidth: defaultDockWidth,
|
|
36
|
+
peekHeight: window.innerHeight * 0.42,
|
|
37
|
+
sources: [],
|
|
38
|
+
activeIndex: 0,
|
|
39
|
+
baseSlug: null,
|
|
40
|
+
modeSwitch: true,
|
|
41
|
+
floatingState: { ...DEFAULT_SIZE, x: null, y: null },
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function reducer(state, action) {
|
|
45
|
+
switch (action.type) {
|
|
46
|
+
case "OPEN":
|
|
47
|
+
return {
|
|
48
|
+
...state,
|
|
49
|
+
isOpen: true,
|
|
50
|
+
mode: action.mode || "popup",
|
|
51
|
+
sources: action.sources,
|
|
52
|
+
activeIndex: action.index ?? 0,
|
|
53
|
+
baseSlug: action.baseSlug ?? null,
|
|
54
|
+
modeSwitch: action.modeSwitch ?? true,
|
|
55
|
+
};
|
|
56
|
+
case "CLOSE":
|
|
57
|
+
return {
|
|
58
|
+
...state,
|
|
59
|
+
isOpen: false,
|
|
60
|
+
mode: "popup",
|
|
61
|
+
baseSlug: null,
|
|
62
|
+
modeSwitch: true,
|
|
63
|
+
};
|
|
64
|
+
case "SET_MODE":
|
|
65
|
+
return { ...state, mode: action.mode };
|
|
66
|
+
case "SET_ACTIVE_INDEX":
|
|
67
|
+
return { ...state, activeIndex: action.index };
|
|
68
|
+
case "SET_DOCK_WIDTH":
|
|
69
|
+
return { ...state, dockWidth: action.width };
|
|
70
|
+
case "SET_PEEK_HEIGHT":
|
|
71
|
+
return { ...state, peekHeight: action.height };
|
|
72
|
+
case "SET_FLOATING_STATE":
|
|
73
|
+
return {
|
|
74
|
+
...state,
|
|
75
|
+
floatingState: { ...state.floatingState, ...action.state },
|
|
76
|
+
};
|
|
77
|
+
case "TOGGLE_MODE": {
|
|
78
|
+
let nextMode = "popup";
|
|
79
|
+
if (state.mode === "popup") nextMode = "dock";
|
|
80
|
+
else if (state.mode === "dock") nextMode = "pip";
|
|
81
|
+
else if (state.mode === "pip") nextMode = "dock";
|
|
82
|
+
return { ...state, mode: nextMode };
|
|
83
|
+
}
|
|
84
|
+
default:
|
|
85
|
+
return state;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function PreviewProvider({ children }) {
|
|
89
|
+
const [state, dispatch] = useReducer(reducer, undefined, getInitialState);
|
|
90
|
+
const openPreview = useCallback(
|
|
91
|
+
(
|
|
92
|
+
sources,
|
|
93
|
+
index = 0,
|
|
94
|
+
hashId = null,
|
|
95
|
+
mode = "popup",
|
|
96
|
+
baseSlug = null,
|
|
97
|
+
modeSwitch = true,
|
|
98
|
+
) => {
|
|
99
|
+
if (hashId && typeof window !== "undefined") {
|
|
100
|
+
window.history.replaceState(null, "", "#" + hashId);
|
|
101
|
+
}
|
|
102
|
+
dispatch({ type: "OPEN", sources, index, mode, baseSlug, modeSwitch });
|
|
103
|
+
},
|
|
104
|
+
[],
|
|
105
|
+
);
|
|
106
|
+
const closePreview = useCallback(() => {
|
|
107
|
+
if (typeof window !== "undefined") {
|
|
108
|
+
window.history.replaceState(
|
|
109
|
+
null,
|
|
110
|
+
"",
|
|
111
|
+
window.location.pathname + window.location.search,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
dispatch({ type: "CLOSE" });
|
|
115
|
+
}, []);
|
|
116
|
+
const setMode = useCallback((mode) => {
|
|
117
|
+
dispatch({ type: "SET_MODE", mode });
|
|
118
|
+
}, []);
|
|
119
|
+
const setActiveIndex = useCallback((index) => {
|
|
120
|
+
dispatch({ type: "SET_ACTIVE_INDEX", index });
|
|
121
|
+
}, []);
|
|
122
|
+
const setDockWidth = useCallback((width) => {
|
|
123
|
+
dispatch({ type: "SET_DOCK_WIDTH", width });
|
|
124
|
+
}, []);
|
|
125
|
+
const setPeekHeight = useCallback((height) => {
|
|
126
|
+
dispatch({ type: "SET_PEEK_HEIGHT", height });
|
|
127
|
+
}, []);
|
|
128
|
+
const setFloatingState = useCallback((newState) => {
|
|
129
|
+
dispatch({ type: "SET_FLOATING_STATE", state: newState });
|
|
130
|
+
}, []);
|
|
131
|
+
const toggleMode = useCallback(() => {
|
|
132
|
+
dispatch({ type: "TOGGLE_MODE" });
|
|
133
|
+
}, []);
|
|
134
|
+
return jsxDEV_7x81h0kn(
|
|
135
|
+
PreviewContext.Provider,
|
|
136
|
+
{
|
|
137
|
+
value: {
|
|
138
|
+
...state,
|
|
139
|
+
openPreview,
|
|
140
|
+
closePreview,
|
|
141
|
+
setMode,
|
|
142
|
+
setActiveIndex,
|
|
143
|
+
setDockWidth,
|
|
144
|
+
setPeekHeight,
|
|
145
|
+
setFloatingState,
|
|
146
|
+
toggleMode,
|
|
147
|
+
},
|
|
148
|
+
children,
|
|
149
|
+
},
|
|
150
|
+
undefined,
|
|
151
|
+
false,
|
|
152
|
+
undefined,
|
|
153
|
+
this,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
const DEFAULT_CTX = {
|
|
157
|
+
isOpen: false,
|
|
158
|
+
mode: "popup",
|
|
159
|
+
dockWidth: 420,
|
|
160
|
+
peekHeight: 400,
|
|
161
|
+
sources: [],
|
|
162
|
+
activeIndex: 0,
|
|
163
|
+
baseSlug: null,
|
|
164
|
+
modeSwitch: true,
|
|
165
|
+
floatingState: { x: null, y: null, width: 800, height: 600 },
|
|
166
|
+
openPreview: () => {},
|
|
167
|
+
closePreview: () => {},
|
|
168
|
+
setMode: () => {},
|
|
169
|
+
setActiveIndex: () => {},
|
|
170
|
+
setDockWidth: () => {},
|
|
171
|
+
setPeekHeight: () => {},
|
|
172
|
+
setFloatingState: () => {},
|
|
173
|
+
toggleMode: () => {},
|
|
174
|
+
};
|
|
175
|
+
export function usePreview() {
|
|
176
|
+
return useContext(PreviewContext) ?? DEFAULT_CTX;
|
|
177
|
+
}
|