-
Notifications
You must be signed in to change notification settings - Fork 31
Skybox time settings - Versioning SceneMetada component #1184
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5d5688f
feat: add components to change skybox configs
alejandralevy 8e08ee1
tmp
nicoecheza c634e19
feat: add properties to v1
alejandralevy 93be272
feat: merge migration
alejandralevy ecab779
feat: Fix prop name and initial value
alejandralevy 949a05d
feat: Fix issue with range selector
alejandralevy 4e70308
feat: Add hour selector
alejandralevy 520ba10
feat: Add gradient to hour range field
alejandralevy 00508d4
feat: Remove import and comment
alejandralevy 0f9284b
feat: fix test and remove seconds value
alejandralevy 1d027eb
feat: fix test value
alejandralevy 0f6c8c3
feat: add skybox config on root level
alejandralevy 5ee129f
feat: add direction to skybox config
alejandralevy 2df97c7
feat: fix type errror
alejandralevy 85507f9
feat: remove old components definitions
alejandralevy bae6765
fix: wrong parameter on function and enum values
alejandralevy e4acf71
feat: handle transition mode change with getInputProps hoook
alejandralevy 4b21fd0
feat: fix transition mode not being sent
alejandralevy ae9919d
feat: refactor range hour component
alejandralevy 06af810
feat: remove unnecessary useEffect
alejandralevy 4287992
feat: add useEffect to update state
alejandralevy 237cd90
feat: fix breaking test
alejandralevy 1474bb5
Merge branch 'main' into feat/skybox-time-settings
alejandralevy 5f40711
feat: fix css issue
alejandralevy 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
76 changes: 76 additions & 0 deletions
76
packages/@dcl/inspector/src/components/ui/RangeHourField/RangeHourField.css
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,76 @@ | ||
| @import '../RangeField/RangeField.css'; | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer input[type='time'] { | ||
| width: 85px; | ||
| padding: 4px 8px; | ||
| background-color: var(--background-gray); | ||
| border-radius: 4px; | ||
| border: 1px solid var(--background-gray); | ||
| color: var(--text); | ||
| font-size: 14px; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer input:hover:not(:disabled) { | ||
| border-color: var(--base-09); | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer input:focus { | ||
| outline: none; | ||
| border-color: var(--base-01); | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer input:disabled { | ||
| background-color: var(--base-12); | ||
| border-color: var(--base-12); | ||
| color: var(--base-09); | ||
| cursor: not-allowed; | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer input[type='time']::-webkit-calendar-picker-indicator { | ||
| display: none; | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer .RangeInput { | ||
| background: linear-gradient( | ||
| 90deg, | ||
| #361c75 0%, | ||
| #534787 15%, | ||
| #bf8dac 30%, | ||
| #46cee9 50%, | ||
| #af80a9 70%, | ||
| #714171 85%, | ||
| #40247b 100% | ||
| ) !important; | ||
| height: 8px !important; | ||
| border-radius: 4px !important; | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer .RangeInput::before, | ||
| .RangeHour.Range.Field .RangeContainer .RangeInput::after { | ||
| background: #361c75 !important; | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer .RangeInput::-webkit-slider-thumb { | ||
| background: white !important; | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer .RangeInput::-moz-range-thumb { | ||
| background: white !important; | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer .RangeInput::-ms-thumb { | ||
| background: white !important; | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer .RangeInput::-webkit-slider-runnable-track { | ||
| background: none !important; | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer .RangeInput::-moz-range-track { | ||
| background: none !important; | ||
| } | ||
|
|
||
| .RangeHour.Range.Field .RangeContainer .RangeInput::-ms-track { | ||
| background: none !important; | ||
| } |
120 changes: 120 additions & 0 deletions
120
packages/@dcl/inspector/src/components/ui/RangeHourField/RangeHourField.tsx
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,120 @@ | ||
| import React, { useCallback, useEffect, useMemo, useState } from 'react' | ||
| import cx from 'classnames' | ||
| import { MIDNIGHT_SECONDS } from '../../../components/EntityInspector/SceneInspector/utils' | ||
| import { Props } from './types' | ||
|
|
||
| import './RangeHourField.css' | ||
|
|
||
| const MIN_SECONDS = 0 | ||
| const STEP_SECONDS = 60 | ||
| // 23:59 in seconds | ||
| const MAX_SECONDS = 86340 | ||
|
|
||
| function formatHour(value: number): string { | ||
| const hours = Math.floor(value / 3600) | ||
| const minutes = Math.floor((value % 3600) / 60) | ||
| return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}` | ||
| } | ||
|
|
||
| const RangeHourField = React.forwardRef<HTMLInputElement, Props>((props, ref) => { | ||
| const { disabled, value = 0, onChange, ...rest } = props | ||
|
|
||
| const [time, setTime] = useState({ | ||
| timeInSeconds: Number(value), | ||
| timeInHHMM: formatHour(Number(value)) | ||
| }) | ||
|
|
||
| useEffect(() => { | ||
| const numValue = Number(value) | ||
| if (numValue !== time.timeInSeconds) { | ||
| setTime({ | ||
| timeInSeconds: numValue, | ||
| timeInHHMM: formatHour(numValue) | ||
| }) | ||
| } | ||
| }, [value]) | ||
|
|
||
| const completionPercentage = useMemo(() => { | ||
| const normalizedValue = Math.min(Math.max(time.timeInSeconds, MIN_SECONDS), MAX_SECONDS) | ||
| return ((normalizedValue - MIN_SECONDS) / (MAX_SECONDS - MIN_SECONDS)) * 100 || 0 | ||
| }, [time.timeInSeconds]) | ||
|
|
||
| const trackStyle = { | ||
| '--completionPercentage': `${completionPercentage}%` | ||
| } as any | ||
|
|
||
| const handleChange = useCallback( | ||
| (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| const numValue = parseFloat(e.target.value) | ||
| const valueToSend = numValue === MIN_SECONDS ? MIDNIGHT_SECONDS : numValue | ||
| setTime({ | ||
| timeInSeconds: numValue, | ||
| timeInHHMM: formatHour(numValue) | ||
| }) | ||
| onChange && | ||
| onChange({ | ||
| ...e, | ||
| target: { ...e.target, value: valueToSend.toString() } | ||
| } as React.ChangeEvent<HTMLInputElement>) | ||
| }, | ||
| [onChange] | ||
| ) | ||
|
|
||
| const parseTimeInput = useCallback((timeStr: string): number => { | ||
| const [hours = '0', minutes = '0'] = timeStr.split(':') | ||
| const totalSeconds = parseInt(hours) * 3600 + parseInt(minutes) * 60 | ||
| // When input is 00:00, send MIDNIGHT_SECONDS (86400) | ||
| return totalSeconds === 0 ? MIDNIGHT_SECONDS : totalSeconds | ||
| }, []) | ||
|
|
||
| const handleChangeTextField = useCallback( | ||
| (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| const inputValue = e.target.value | ||
| const seconds = parseTimeInput(inputValue) | ||
| // When input is 00:00, send MIDNIGHT_SECONDS (86400) | ||
| const valueToSend = seconds === MIN_SECONDS ? MIDNIGHT_SECONDS : seconds | ||
| setTime({ | ||
| timeInSeconds: seconds, | ||
| timeInHHMM: inputValue | ||
| }) | ||
| onChange && | ||
| onChange({ | ||
| ...e, | ||
| target: { ...e.target, value: valueToSend.toString() } | ||
| } as React.ChangeEvent<HTMLInputElement>) | ||
| }, | ||
| [onChange, parseTimeInput] | ||
| ) | ||
|
|
||
| return ( | ||
| <div className="Range Field RangeHour"> | ||
| <div className={cx('RangeContainer', { disabled })}> | ||
| <div className="InputContainer"> | ||
| <input | ||
| ref={ref} | ||
| type="range" | ||
| className="RangeInput" | ||
| min={MIN_SECONDS} | ||
| max={MAX_SECONDS} | ||
| step={STEP_SECONDS} | ||
| value={time.timeInSeconds} | ||
| style={trackStyle} | ||
| disabled={disabled} | ||
| onChange={handleChange} | ||
| {...rest} | ||
| /> | ||
| </div> | ||
| <input | ||
| className="RangeTextInput" | ||
| type="time" | ||
| value={time.timeInHHMM} | ||
| disabled={disabled} | ||
| onChange={handleChangeTextField} | ||
| onBlur={handleChangeTextField} | ||
| /> | ||
| </div> | ||
| </div> | ||
| ) | ||
| }) | ||
|
|
||
| export default React.memo(RangeHourField) |
7 changes: 7 additions & 0 deletions
7
packages/@dcl/inspector/src/components/ui/RangeHourField/types.ts
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,7 @@ | ||
| import { InputHTMLAttributes } from 'react' | ||
|
|
||
| export interface Props extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'> { | ||
| value?: number | ||
| disabled?: boolean | ||
| onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void | ||
| } |
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.
same as above for all the previous ones