-
-
Notifications
You must be signed in to change notification settings - Fork 53
Mock Browser #168
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
Draft
You-J
wants to merge
22
commits into
staging
Choose a base branch
from
@ui/mock-browser
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Mock Browser #168
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7b4d1c8
setup structure
You-J 6cc4ca3
update readme
You-J f40aa14
set storybook for component
You-J 0868ced
update directory names
softmarshmallow c1fbac2
add global show / hide navigation animation by preview scroll
softmarshmallow 9cb8135
adjust animation
softmarshmallow 4f58c4b
stash add component using storybook
You-J baf7622
add scroll anim trigger to code area & add 2line tab under root nav app
softmarshmallow 6b7058a
shadow on only code preview screen
softmarshmallow 50b30e5
Merge pull request #167 from gridaco/app-navigation
softmarshmallow 97c8c33
update root scripts
softmarshmallow 38a1d4c
fix storybook issue
You-J 9575cd1
fix storybook emotion version issue
You-J 4ad55b6
add storybook root
You-J 66f7cdb
add refresh btn
You-J 9d94a2f
rename
You-J 48f42c1
add component index
You-J 4cf0316
add address bar
You-J 1e970d9
stash add browser bar
You-J 2f809f8
Merge branch '@ui/mock-browser' of https://github.com/gridaco/assista…
You-J cc394da
stash add attr in browser-bar
You-J bcef2a9
fix unconfirmed design invisible
You-J 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,43 @@ | ||
// https://stackoverflow.com/a/65970945/12377179 | ||
|
||
const path = require("path"); | ||
const fs = require("fs"); | ||
|
||
function getPackageDir(filepath) { | ||
let currDir = path.dirname(require.resolve(filepath)); | ||
while (true) { | ||
if (fs.existsSync(path.join(currDir, "package.json"))) { | ||
return currDir; | ||
} | ||
const { dir, root } = path.parse(currDir); | ||
if (dir === root) { | ||
throw new Error( | ||
`Could not find package.json in the parent directories starting from ${filepath}.` | ||
); | ||
} | ||
currDir = dir; | ||
} | ||
} | ||
|
||
module.exports = { | ||
stories: [ | ||
"../app/lib/components/**/*.stories.mdx", | ||
"../app/lib/components/**/*.stories.@(js|jsx|ts|tsx)", | ||
"**/*.stories.mdx", | ||
"**/*.stories.@(js|jsx|ts|tsx)", | ||
], | ||
addons: ["@storybook/addon-links", "@storybook/addon-essentials"], | ||
|
||
webpackFinal: async (config) => ({ | ||
...config, | ||
resolve: { | ||
...config.resolve, | ||
alias: { | ||
...config.resolve.alias, | ||
"@emotion/core": getPackageDir("@emotion/react"), | ||
"@emotion/styled": getPackageDir("@emotion/styled"), | ||
"emotion-theming": getPackageDir("@emotion/react"), | ||
}, | ||
}, | ||
}), | ||
}; |
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
# General motions | ||
|
||
Motions only ! - no symantic ui components allowed here. |
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,2 @@ | ||
export * from "./update-hide-by-scroll-position-and-velocity"; | ||
export * from "./smooth-dampings"; |
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,4 @@ | ||
export const smooth_damping_hide_motion_transition = { | ||
ease: [0.1, 0.25, 0.3, 1], | ||
duration: 0.6, | ||
}; |
107 changes: 107 additions & 0 deletions
107
app/lib/components/motions/update-hide-by-scroll-position-and-velocity/index.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,107 @@ | ||
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({ | ||
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, | ||
}, | ||
}: { | ||
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 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. | ||
const scroll_progress_percentage = scrollYProgress.get(); | ||
|
||
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, | ||
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 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,50 @@ | ||
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"} | ||
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: -40 }, | ||
}; | ||
|
||
return ( | ||
<motion.div | ||
variants={variants_for_child} | ||
animate={hidden ? "hidden" : "visible"} | ||
transition={smooth_damping_hide_motion_transition} | ||
> | ||
{children} | ||
</motion.div> | ||
); | ||
} |
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,57 @@ | ||
import React from "react"; | ||
import { css } from "@emotion/react"; | ||
import styled from "@emotion/styled"; | ||
|
||
export function WorkmodeButton(props: { | ||
name: string; | ||
active: boolean; | ||
onClick: () => void; | ||
}) { | ||
return ( | ||
<> | ||
<WorkmodeLabel active={props.active} onClick={props.onClick}> | ||
{props.name} | ||
</WorkmodeLabel> | ||
</> | ||
); | ||
} | ||
interface Props { | ||
active: boolean; | ||
} | ||
|
||
const WorkmodeLabel = styled.h3<Props>` | ||
display: flex; | ||
text-transform: capitalize; | ||
font-size: 21px; | ||
letter-spacing: 0em; | ||
cursor: pointer; | ||
user-select: none; | ||
|
||
// reset for h3 init style | ||
margin: 0; | ||
|
||
&:first-child { | ||
margin-right: 12px; | ||
} | ||
|
||
${(props) => | ||
props.active | ||
? css` | ||
font-weight: 700; | ||
line-height: 26px; | ||
color: #000; | ||
` | ||
: css` | ||
font-weight: 400; | ||
line-height: 25px; | ||
color: #cfcfcf; | ||
|
||
&:hover { | ||
font-size: 21px; | ||
font-weight: 400; | ||
line-height: 25px; | ||
letter-spacing: 0em; | ||
color: #606060; | ||
} | ||
`} | ||
`; |
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,6 @@ | ||
import { atom } from "recoil"; | ||
|
||
export const hide_navigation = atom<boolean>({ | ||
key: "hide_navigation", | ||
default: false, | ||
}); |
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.
You can't do this.
pacakages/submoule-package/**/*.stories.mdx
from another repository will also be included. we don't want this