Repository navigation
feat(editor): integrate Key23 authentic 3D keycaps customizer & keyboard timeline track #2406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emirhangungormez
wants to merge
9
commits into
CapSoftware:main
Choose a base branch
from
emirhangungormez:feat/key23-keycap-design
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,274
−24
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f9158b7
feat(editor): enhance keyboard overlay with Key23 authentic 3D keycap…
emirhangungormez 61dd3da
feat(editor): integrate Key23 3D keycaps customizer and keyboard time…
emirhangungormez 6bf38d0
fix: address Greptile review — kebab-case filenames, typed props, sho…
emirhangungormez 8127140
fix(editor): address review feedback — drop branding, revert select i…
emirhangungormez 7d56741
fix(rendering): respect custom user colors in export while preserving…
emirhangungormez 25edda7
fix(editor): support custom text and background colors in keycap prev…
emirhangungormez 302dd6a
fix(editor): generate unique SVG gradient IDs per keycap instance to …
emirhangungormez 99d7148
fix(rendering,editor): respect user-chosen colors during export and a…
emirhangungormez c26a6e7
fix(editor): apply custom colors to classic box keycaps and chassis p…
emirhangungormez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import { createMemo, Show } from "solid-js"; | ||
| import { | ||
| defaultKeyboardSettings, | ||
| type KeycapStyle, | ||
| type KeycapTheme, | ||
| } from "~/store/keyboard"; | ||
| import { useEditorContext } from "./context"; | ||
| import { KeycapPreviewCluster, parseShortcutKeys } from "./keycap-renderer"; | ||
|
|
||
| type KeyboardOverlayProps = { | ||
| size: { width: number; height: number }; | ||
| }; | ||
|
|
||
| export function KeyboardOverlay(props: KeyboardOverlayProps) { | ||
| const { project, editorState } = useEditorContext(); | ||
|
|
||
| const currentAbsoluteTime = () => | ||
| editorState.previewTime ?? editorState.playbackTime ?? 0; | ||
|
|
||
| const settings = createMemo(() => ({ | ||
| ...defaultKeyboardSettings, | ||
| ...project.keyboard?.settings, | ||
| })); | ||
|
|
||
| const isTrackEnabled = () => editorState.timeline.tracks.keyboard ?? true; | ||
|
|
||
| const activeSegment = createMemo(() => { | ||
| if (!settings().enabled || !isTrackEnabled()) return null; | ||
| const time = currentAbsoluteTime(); | ||
| const segments = project.timeline?.keyboardSegments ?? []; | ||
| return segments.find((seg) => time >= seg.start && time <= seg.end) ?? null; | ||
| }); | ||
|
|
||
| const parsedKeys = createMemo(() => { | ||
| const seg = activeSegment(); | ||
| if (!seg) return []; | ||
| return parseShortcutKeys(seg.displayText || ""); | ||
| }); | ||
|
|
||
| const positionClasses = createMemo(() => { | ||
| const pos = settings().position || "bottom-center"; | ||
| switch (pos) { | ||
| case "top-left": | ||
| return "items-start justify-start pt-14 pl-12"; | ||
| case "top-center": | ||
| case "top": | ||
| return "items-start justify-center pt-14"; | ||
| case "top-right": | ||
| return "items-start justify-end pt-14 pr-12"; | ||
| case "bottom-left": | ||
| return "items-end justify-start pb-32 pl-12"; | ||
| case "bottom-right": | ||
| return "items-end justify-end pb-32 pr-12"; | ||
| default: | ||
| return "items-end justify-center pb-32"; | ||
| } | ||
| }); | ||
|
|
||
| return ( | ||
| <Show when={activeSegment()}> | ||
| <div | ||
| class={`absolute inset-0 pointer-events-none flex ${positionClasses()} z-30 transition-all duration-150 ease-out`} | ||
| style={{ | ||
| width: `${props.size.width}px`, | ||
| height: `${props.size.height}px`, | ||
| }} | ||
| > | ||
| <div class="animate-in fade-in zoom-in-95 duration-100"> | ||
| <KeycapPreviewCluster | ||
| keys={parsedKeys()} | ||
| style={(settings().style || "pbt") as KeycapStyle} | ||
| theme={(settings().theme || "white") as KeycapTheme} | ||
| showChassis={settings().showChassis ?? true} | ||
| use3D={settings().keycapMode ?? true} | ||
| scale={Math.min(1.2, Math.max(0.7, props.size.width / 1200))} | ||
| customTextColor={activeSegment()?.colorOverride ?? settings().color} | ||
| customBgColor={ | ||
| activeSegment()?.backgroundColorOverride ?? | ||
| settings().backgroundColor | ||
| } | ||
| /> | ||
|
emirhangungormez marked this conversation as resolved.
|
||
| </div> | ||
| </div> | ||
| </Show> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.