-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Make "Reanimated" title in docs interactive. #5766
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
latekvo
merged 33 commits into
software-mansion:main
from
latekvo:@latekvo/docs/make-title-movable
Mar 18, 2024
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
70b9aa5
Minimal functional version
latekvo 46f5eb0
Reworked movement so that jittering is insignificant and layout is no…
latekvo a4ef1bc
last functional version, added mouse capture
latekvo f7f65db
added panning, visual changes
latekvo da5e289
converted rendering system to use references instead of rerenders
latekvo 08b0763
prettier - fixed file formatting for PR
latekvo c37135f
Merge branch 'main' into @latekvo/docs/make-title-movable
latekvo cf75df5
Merge branch 'main' into @latekvo/docs/make-title-movable
latekvo 18e9440
Apply css suggestion.
latekvo 7efee6d
Applied review suggestion.
latekvo c752c64
Fixed sudden moves being stopped.
latekvo db00f72
Added unstaged changes from previous commit.
latekvo e44b0d0
By default, title is not interactive, and looks exactly how it used t…
latekvo bc9b9cc
Removed unnecessary useEffects.
latekvo 0207edc
Simplified code. Ran prettier.
latekvo 2df6ca1
Resolve merge
latekvo 9791989
Unify styling for interactive and non-interactive components.
latekvo e5af116
Fix styling for mobile devices, this may require more work.
latekvo 960642f
Fix failing git checks. Ran prettier.
latekvo 7bb1ceb
Fixed website layout so it appears on mobile exactly how it used to b…
latekvo 69287e6
Fix git CI errors.
latekvo 13bcce4
Cleaned up code.
latekvo 96f78b6
Simplify code, fix formatting.
latekvo 0fb792d
Moved logic to a separate file.
latekvo 9662155
Remove unnecessary code.
latekvo 3c4ab42
Merge branch 'main' into @latekvo/docs/make-title-movable
latekvo 475ef5a
Updated styles to match their original look on mobile.
latekvo e8db12b
Merge branch 'software-mansion:@latekvo/docs/make-title-movable' into…
latekvo a6166c8
Fix lint errors.
latekvo b7e2d0c
Merge branch 'software-mansion:@latekvo/docs/make-title-movable' into…
latekvo 5e2b849
Apply review suggestion.
latekvo 95cf005
Merge branch 'software-mansion:@latekvo/docs/make-title-movable' into…
latekvo a0af3fa
Merge branch 'main' into @latekvo/docs/make-title-movable
latekvo 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
76 changes: 76 additions & 0 deletions
76
docs/src/components/Hero/SelectedLabel/SelectionBox/index.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,76 @@ | ||
| import clsx from 'clsx'; | ||
| import React from 'react'; | ||
| import styles from './styles.module.css'; | ||
| import Draggable from 'react-draggable'; | ||
|
|
||
| export enum DraggableId { | ||
| TOP_LEFT, | ||
| TOP_RIGHT, | ||
| BOTTOM_LEFT, | ||
| BOTTOM_RIGHT, | ||
| CENTER, | ||
| } | ||
|
|
||
| const getClassListByIdentifier = ( | ||
| identifier: DraggableId, | ||
| isInteractive: boolean | ||
| ) => { | ||
| const isBottom = | ||
| identifier == DraggableId.BOTTOM_LEFT || | ||
| identifier == DraggableId.BOTTOM_RIGHT; | ||
| const isLeft = | ||
| identifier == DraggableId.BOTTOM_LEFT || identifier == DraggableId.TOP_LEFT; | ||
| const isCenter = identifier === DraggableId.CENTER; | ||
|
|
||
| let classList = styles.centerDraggable; | ||
|
|
||
| if (!isCenter) { | ||
| classList = clsx( | ||
| styles.selectionBox, | ||
| isBottom ? styles.boxLower : styles.boxUpper, | ||
| isLeft ? styles.boxLeft : styles.boxRight | ||
| ); | ||
| } | ||
|
|
||
| if (isInteractive) { | ||
| classList = clsx(classList, styles.movable); | ||
| } | ||
|
|
||
| return classList; | ||
| }; | ||
|
|
||
| const SelectionBox: React.FC<{ | ||
| propagationFunction: ( | ||
| movementDelta: { x: number; y: number }, | ||
| draggableIdentifier: DraggableId | ||
| ) => void; | ||
| draggableIdentifier: DraggableId; | ||
| children?: React.ReactNode; | ||
| isInteractive: boolean; | ||
| }> = ({ | ||
| propagationFunction, | ||
| draggableIdentifier, | ||
| children, | ||
| isInteractive, | ||
| }) => { | ||
| const classList = getClassListByIdentifier( | ||
| draggableIdentifier, | ||
| isInteractive | ||
| ); | ||
|
|
||
| return ( | ||
| <Draggable | ||
| onDrag={(event: any) => { | ||
| propagationFunction( | ||
| { x: event.movementX, y: event.movementY }, | ||
| draggableIdentifier | ||
| ); | ||
| }} | ||
| allowAnyClick={false} | ||
| axis={'none'}> | ||
| <div className={classList}>{children}</div> | ||
| </Draggable> | ||
| ); | ||
| }; | ||
|
|
||
| export default SelectionBox; | ||
64 changes: 64 additions & 0 deletions
64
docs/src/components/Hero/SelectedLabel/SelectionBox/styles.module.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,64 @@ | ||
| .movable { | ||
| cursor: grab; | ||
| } | ||
|
|
||
| .movable:active { | ||
| cursor: grabbing; | ||
| } | ||
|
|
||
| .selectionBox { | ||
| position: absolute; | ||
| width: 12px; | ||
| height: 12px; | ||
| z-index: 2; | ||
| background: var(--swm-white); | ||
| border: 2px solid var(--swm-landing-heading-selected-border); | ||
| transition: scale 50ms ease-in-out; | ||
| } | ||
|
|
||
| .movable.selectionBox:active { | ||
| scale: 1.35; | ||
| } | ||
|
|
||
| .movable.selectionBox:hover { | ||
| scale: 1.35; | ||
| } | ||
|
|
||
| .centerDraggable { | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
|
|
||
| .boxUpper { | ||
| top: -7px; | ||
| } | ||
|
|
||
| .boxLower { | ||
| bottom: -13px; | ||
| } | ||
|
|
||
| .boxLeft { | ||
| left: -15px; | ||
| } | ||
|
|
||
| .boxRight { | ||
| right: -15px; | ||
| } | ||
|
|
||
| @media (max-width: 768px) { | ||
| .boxUpper { | ||
| top: -11px; | ||
| } | ||
|
|
||
| .boxLower { | ||
| bottom: -13px; | ||
| } | ||
|
|
||
| .boxLeft { | ||
| left: -7px; | ||
| } | ||
|
|
||
| .boxRight { | ||
| right: -7px; | ||
| } | ||
| } |
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
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.