-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Set timestamps in a chapter of a study #19728
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
Closed
nstillman-te
wants to merge
1
commit into
lichess-org:master
from
TechEmpower:inline-clock-editing-15009
Closed
Changes from all commits
Commits
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
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
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
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 |
|---|---|---|
|
|
@@ -39,6 +39,8 @@ $clock-height: 20px; | |
| height: $clock-height; | ||
| font-weight: bold; | ||
| text-align: center; | ||
| /* Reserve border space so empty-editable dashed border doesn't cause 1px shift when .active toggles */ | ||
| border: 1px solid transparent; | ||
|
|
||
| &.active { | ||
| background: $m-primary_bg--mix-30; | ||
|
|
@@ -53,6 +55,61 @@ $clock-height: 20px; | |
| margin-inline-end: 0.4em; | ||
| color: $c-accent; | ||
| } | ||
|
|
||
| &--editable { | ||
| cursor: pointer; | ||
| border: 1px dashed $c-primary; | ||
| @media (hover: hover) { | ||
| &:hover { | ||
| /* Same effect as move sidebar; --c-base is only set inside .tview2 so use $c-font here */ | ||
| background: color-mix(in srgb, $c-font 15%, transparent); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| &--editing { | ||
| flex-shrink: 0; | ||
| min-width: 0; /* allow input to size */ | ||
| .analyse__clock-input { | ||
| min-width: 10em; | ||
| width: 10em; | ||
| padding: 0 0.4em; | ||
| font: inherit; | ||
| font-weight: bold; | ||
| text-align: center; | ||
| border: 1px solid $c-border; | ||
| border-radius: 3px; | ||
| background: $c-bg-box; | ||
| box-sizing: border-box; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. superfluous |
||
| } | ||
| } | ||
|
|
||
| .analyse__clock-input--error { | ||
| border-color: var(--c-bad, #c23) !important; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just |
||
| animation: clock-shake 0.3s ease; | ||
| &:focus { | ||
| /* Inset box-shadow so the error ring is visible when the top strip is partially covered by the board */ | ||
| outline: none; | ||
| box-shadow: inset 0 0 0 2px var(--c-bad, #c23); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @keyframes clock-shake { | ||
| 0%, | ||
| 100% { | ||
| transform: translateX(0); | ||
| } | ||
| 25% { | ||
| transform: translateX(-3px); | ||
| } | ||
| 75% { | ||
| transform: translateX(3px); | ||
| } | ||
| } | ||
|
|
||
| .analyse__clock-placeholder { | ||
| opacity: 0.7; | ||
| } | ||
|
|
||
| .material { | ||
|
|
||
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
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,43 @@ | ||
| /** Parse time string (H:MM:SS, MM:SS, M:SS, SS, or SS.t for tenths) to centis. Returns undefined if invalid. */ | ||
| export function parseTimeToCentis(str: string): number | undefined { | ||
| const s = str.trim(); | ||
| if (s === '' || s === '--:--') return undefined; | ||
| const parts = s.split(':').map(p => p.trim()); | ||
| if (parts.some(p => p === '')) return undefined; | ||
| const lastPart = parts[parts.length - 1]; | ||
| const lastNum = parseFloat(lastPart); | ||
| if (isNaN(lastNum) || lastNum < 0) return undefined; | ||
| const wholeParts = parts.slice(0, -1).map(p => parseInt(p, 10)); | ||
| if (wholeParts.some(n => isNaN(n) || n < 0)) return undefined; | ||
| let seconds = 0; | ||
| if (parts.length === 1) { | ||
| seconds = lastNum; | ||
| } else if (parts.length === 2) { | ||
| seconds = parseInt(parts[0], 10) * 60 + lastNum; | ||
| } else if (parts.length === 3) { | ||
| seconds = parseInt(parts[0], 10) * 3600 + parseInt(parts[1], 10) * 60 + lastNum; | ||
| } else { | ||
| return undefined; | ||
| } | ||
| return Math.round(seconds * 100); | ||
| } | ||
|
|
||
| const pad2 = (num: number): string => (num < 10 ? '0' : '') + num; | ||
|
|
||
| /** Format centis as H:MM:SS, MM:SS, or SS.t for display in input (tenths when non-integer). */ | ||
| export function formatClockFromCentis(centis: number): string { | ||
| if (centis <= 0) return '0:00:00'; | ||
| const date = new Date(centis * 10), | ||
| hours = Math.floor(centis / 360000), | ||
| mins = date.getUTCMinutes(), | ||
| secs = date.getUTCSeconds(), | ||
| tenths = Math.round((centis % 100) / 10); | ||
| const secStr = tenths > 0 ? `${pad2(secs)}.${tenths}` : pad2(secs); | ||
| if (hours > 0) { | ||
| return `${hours}:${pad2(mins)}:${secStr}`; | ||
| } | ||
| if (mins > 0) { | ||
| return `${mins}:${secStr}`; | ||
| } | ||
| return tenths > 0 ? `${secs}.${tenths}` : `${secs}`; | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug