-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cover: Video - Add position controls (#22531)
* Add initial support for video in FocalPointPicker * Add FocalPointPicker stories + update README. * Improve FocalPointPicker and add Grid * Update docs manifest * Add click + keyboard arrow movements to update position * Show grid on drag. Improve click/drag interaction. * Apply Cover background position on save.js * Refactor FocalPointPicker class component. Adjust styles. * Refactor FocalPointPicker Media and add tests * Refactor FocalPointPicker updateValue parsing. Improve grid CSS rendering. * Refactor percentage value updates from FocalPointPicker and sub components * Add side label alignment for InputControl. Update controls in FocalPointPicker * Add shift + drag to jump by 10. Improve stability of calculations on load * Update fixture for Cover * Fix file path for media import in test * Update Flex component from master * Add .ogv for video file * Format style files * Fix FocalPointPicker to handle reset value cases (e.g. UNDO) * Improve rendering styles of FocalPointPicker media and picker * Fix import path for roundClamp * Ensure Cover save does not generated empty styles if there are no video bg positions * Remove unused focal-point-picker style * Adjusted super call in FocalPointPicker constructor * Adjust useRevealAnimation hook with useUpdateEffect for debouncing * Simplifiy showFocalPointPicker logic in cover/edit * Fix position rounding for cover/save.js
- Loading branch information
Q
authored
Jul 15, 2020
1 parent
11a0cd5
commit ff313a7
Showing
20 changed files
with
979 additions
and
331 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,70 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { noop } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { | ||
UnitControl as BaseUnitControl, | ||
ControlWrapper, | ||
} from './styles/focal-point-picker-style'; | ||
import { fractionToPercentage } from './utils'; | ||
|
||
const TEXTCONTROL_MIN = 0; | ||
const TEXTCONTROL_MAX = 100; | ||
|
||
export default function FocalPointPickerControls( { | ||
onChange = noop, | ||
percentages = { | ||
x: 0.5, | ||
y: 0.5, | ||
}, | ||
} ) { | ||
const valueX = fractionToPercentage( percentages.x ); | ||
const valueY = fractionToPercentage( percentages.y ); | ||
|
||
const handleOnXChange = ( next ) => { | ||
onChange( { ...percentages, x: parseInt( next ) / 100 } ); | ||
}; | ||
const handleOnYChange = ( next ) => { | ||
onChange( { ...percentages, y: parseInt( next ) / 100 } ); | ||
}; | ||
|
||
return ( | ||
<ControlWrapper className="focal-point-picker__controls"> | ||
<UnitControl | ||
label={ __( 'Left' ) } | ||
value={ valueX } | ||
onChange={ handleOnXChange } | ||
dragDirection="e" | ||
/> | ||
<UnitControl | ||
label={ __( 'Top' ) } | ||
value={ valueY } | ||
onChange={ handleOnYChange } | ||
dragDirection="s" | ||
/> | ||
</ControlWrapper> | ||
); | ||
} | ||
|
||
function UnitControl( props ) { | ||
return ( | ||
<BaseUnitControl | ||
className="focal-point-picker__controls-position-unit-control" | ||
labelPosition="side" | ||
max={ TEXTCONTROL_MAX } | ||
min={ TEXTCONTROL_MIN } | ||
unit="%" | ||
units={ [ { value: '%', label: '%' } ] } | ||
{ ...props } | ||
/> | ||
); | ||
} |
Oops, something went wrong.