-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from gridaco/staging
Assistant 2021.9 Release
- Loading branch information
Showing
307 changed files
with
25,750 additions
and
3,651 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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
// DO NOT REMOVE THIS LINE | ||
import "../lib/pages/code/__plugin"; | ||
import "@app/data-mapper/__plugin"; | ||
import "@app/design-to-code/__plugin"; | ||
import "@app/design-lint/__plugin"; | ||
|
||
// disabled on staging | ||
// import "@app/data-mapper/__plugin"; | ||
// import "@app/design-text-code-syntax-highlight/__plugin"; |
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
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
# General motions | ||
|
||
Motions only ! - no symantic ui components allowed here. |
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,2 @@ | ||
export * from "./update-hide-by-scroll-position-and-velocity"; | ||
export * from "./smooth-dampings"; |
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,4 @@ | ||
export const smooth_damping_hide_motion_transition = { | ||
ease: [0.1, 0.25, 0.3, 1], | ||
duration: 0.6, | ||
}; |
121 changes: 121 additions & 0 deletions
121
app/lib/components/motions/update-hide-by-scroll-position-and-velocity/index.ts
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,121 @@ | ||
import { useState, useEffect, RefObject } from "react"; | ||
import { ScrollMotionValues } from "framer-motion"; | ||
import { useElementScroll } from "framer-motion"; | ||
|
||
export function update_hide_by_scroll_position_and_velocity({ | ||
scrollY, | ||
scrollYProgress, | ||
is_animating_by_intense_scrolling, | ||
on_animating_by_intense_scrolling, | ||
on_change, | ||
options = { | ||
top_sensitivity: 0.01, | ||
bottom_sensitivity: 0.01, | ||
define_intense_velocity: 1, | ||
do_show_on_bottom_hit: true, | ||
}, | ||
}: { | ||
scrollY: ScrollMotionValues["scrollY"]; | ||
scrollYProgress: ScrollMotionValues["scrollYProgress"]; | ||
is_animating_by_intense_scrolling: boolean; | ||
on_animating_by_intense_scrolling: (v?: true) => void; | ||
on_change: (hide: boolean) => void; | ||
options?: { | ||
top_sensitivity: number; | ||
bottom_sensitivity: number; | ||
define_intense_velocity: number; | ||
do_show_on_bottom_hit: boolean; | ||
}; | ||
}) { | ||
const scroll_progress_percentage = scrollYProgress.get(); | ||
const ydiff = Math.abs(scrollY.get() - scrollY.getPrevious()); | ||
if ( | ||
// don't execute if diff is `<=` than 2. - this is a really small scroll | ||
ydiff <= 2 && | ||
// except for bottom / top | ||
scroll_progress_percentage !== 0 && | ||
scroll_progress_percentage !== 1 | ||
) { | ||
return; | ||
} | ||
|
||
const velocity = scrollYProgress.getVelocity(); | ||
const velocity_abs = Math.abs(velocity); | ||
if ( | ||
// if < 20, this event is not triggered by human, or caused by extremely short scroll area, causing high velocity. | ||
velocity_abs > 20 || | ||
scrollYProgress.get() == scrollYProgress.getPrevious() | ||
) { | ||
return; | ||
} | ||
const is_intense_scrolling = velocity_abs > options.define_intense_velocity; | ||
const direction = velocity > 0 ? "down" : "up"; // this is ok. velocity can't be 0. | ||
|
||
if (scroll_progress_percentage >= 1 - options.bottom_sensitivity) { | ||
if (options.do_show_on_bottom_hit) { | ||
// bottom = show | ||
on_change(false); | ||
} | ||
} else if (scroll_progress_percentage <= options.top_sensitivity) { | ||
switch (direction) { | ||
// top + down = hide | ||
case "down": | ||
if (!is_intense_scrolling) { | ||
on_change(true); | ||
} | ||
break; | ||
case "up": | ||
// top + up = show | ||
on_change(false); | ||
break; | ||
} | ||
} else { | ||
if (is_intense_scrolling) { | ||
switch (direction) { | ||
// scroll intense + down = hide | ||
case "down": | ||
on_change(true); | ||
break; | ||
// scroll intense + up = show | ||
case "up": | ||
on_animating_by_intense_scrolling(true); | ||
on_change(false); | ||
break; | ||
} | ||
} else { | ||
if (!is_animating_by_intense_scrolling) { | ||
// middle = hide | ||
on_change(true); | ||
} | ||
} | ||
} | ||
} | ||
|
||
export function useScrollTriggeredAnimation(el: RefObject<HTMLElement>) { | ||
const { scrollYProgress, scrollY } = useElementScroll(el); | ||
const [hide, setHide] = useState(false); | ||
let is_animating_by_intense_scrolling = false; | ||
useEffect(() => { | ||
return scrollYProgress.onChange(() => | ||
update_hide_by_scroll_position_and_velocity({ | ||
scrollYProgress, | ||
scrollY, | ||
is_animating_by_intense_scrolling, | ||
on_animating_by_intense_scrolling: () => { | ||
is_animating_by_intense_scrolling = true; | ||
}, | ||
on_change: (hide) => { | ||
setHide(hide); | ||
}, | ||
options: { | ||
do_show_on_bottom_hit: false, | ||
top_sensitivity: 0.05, | ||
bottom_sensitivity: 0.1, | ||
define_intense_velocity: 50, | ||
}, | ||
}) | ||
); | ||
}); | ||
|
||
return hide; | ||
} |
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,53 @@ | ||
import React from "react"; | ||
import { motion } from "framer-motion"; | ||
import { smooth_damping_hide_motion_transition } from "../motions"; | ||
|
||
export function AppbarContainerMotion({ | ||
hidden, | ||
children, | ||
}: { | ||
hidden: boolean; | ||
children: JSX.Element | JSX.Element[]; | ||
}) { | ||
/** add this const **/ | ||
const variants_for_container = { | ||
visible: { opacity: 1 }, | ||
hidden: { opacity: 0, height: 0 }, | ||
}; | ||
|
||
return ( | ||
<motion.div | ||
variants={variants_for_container} | ||
animate={hidden ? "hidden" : "visible"} | ||
style={{ | ||
zIndex: 1, | ||
}} | ||
transition={smooth_damping_hide_motion_transition} | ||
> | ||
{children} | ||
</motion.div> | ||
); | ||
} | ||
|
||
export function AppbarContentMotion({ | ||
hidden, | ||
children, | ||
}: { | ||
hidden: boolean; | ||
children: JSX.Element | JSX.Element[]; | ||
}) { | ||
const variants_for_child = { | ||
visible: { y: 0 }, | ||
hidden: { y: -100 }, | ||
}; | ||
|
||
return ( | ||
<motion.div | ||
variants={variants_for_child} | ||
animate={hidden ? "hidden" : "visible"} | ||
transition={smooth_damping_hide_motion_transition} | ||
> | ||
{children} | ||
</motion.div> | ||
); | ||
} |
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 |
---|---|---|
|
@@ -35,7 +35,5 @@ const Button = styled.div` | |
svg { | ||
fill: #cfcfcf; | ||
width: 25px; | ||
height: 34px; | ||
} | ||
`; |
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,24 @@ | ||
import React from "react"; | ||
import styled from "@emotion/styled"; | ||
import { useHistory } from "react-router"; | ||
import BackArrow from "@assistant/icons/back-arrow"; | ||
|
||
export function RouteBackButton() { | ||
const history = useHistory(); | ||
|
||
const close = () => { | ||
history.goBack(); | ||
}; | ||
|
||
return ( | ||
<BackIcon onClick={close}> | ||
<BackArrow /> | ||
</BackIcon> | ||
); | ||
} | ||
|
||
export const BackIcon = styled.div` | ||
width: 24px; | ||
height: 24px; | ||
cursor: pointer; | ||
`; |
Oops, something went wrong.
22f0813
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.
Successfully deployed to the following URLs: