Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork54
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:staging
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Mock Browser#168
Changes from13 commits
7b4d1c86cc4ca3f40aa140868cedc1fbac29cb81354f58c4bbaf76226b7058a50b30e597c8c3338a1d4c9575cd14ad55b666f7cdb9d94a2f48f42c14cf03161e970d92f809f8cc394dabcef2a9File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,43 @@ | ||
| // https://stackoverflow.com/a/65970945/12377179 | ||
| constpath=require("path"); | ||
| constfs=require("fs"); | ||
| functiongetPackageDir(filepath){ | ||
| letcurrDir=path.dirname(require.resolve(filepath)); | ||
| while(true){ | ||
| if(fs.existsSync(path.join(currDir,"package.json"))){ | ||
| returncurrDir; | ||
| } | ||
| const{ dir, root}=path.parse(currDir); | ||
| if(dir===root){ | ||
| thrownewError( | ||
| `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", | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. You can't do this.
| ||
| "**/*.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"), | ||
| }, | ||
| }, | ||
| }), | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +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: [ | ||
| "../components/**/*.stories.mdx", | ||
| "../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"), | ||
| }, | ||
| }, | ||
| }), | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| export const parameters = { | ||
| actions: { argTypesRegex: "^on[A-Z].*" }, | ||
| controls: { | ||
| matchers: { | ||
| color: /(background|color)$/i, | ||
| date: /Date$/, | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # `@ui/mock-browser` | ||
|  |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { Meta, Story, Preview, Props } from "@storybook/addon-docs/blocks"; | ||
| import { BrowserBar } from "../browser-bar"; | ||
| <Meta title="browser-bar" /> | ||
| # Preview | ||
| <Preview> | ||
| <Story name="based"> | ||
| <div style={{ height: "50px", width: "100vw" }}> | ||
| <BrowserBar /> | ||
| </div> | ||
| </Story> | ||
| </Preview> | ||
| # Props |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| import React from "react"; | ||
| import styled from "@emotion/styled"; | ||
| import { css } from "@emotion/react"; | ||
| import { AddressBar, BrowserNavigationBfButtonGroup } from "../components"; | ||
| interface BrowserBarProps { | ||
| history?: any; | ||
| } | ||
| // FIXME: handling xl xs size default xl | ||
| export function BrowserBar() { | ||
| return ( | ||
| <Wrapper> | ||
| <BrowserNavigationBfButtonGroupWrap> | ||
| <BrowserNavigationBfButtonGroup | ||
| forwardEnable={true} | ||
| backEnable={true} | ||
| handleClick={(isBack) => { | ||
| console.log(isBack); | ||
| }} | ||
| /> | ||
| </BrowserNavigationBfButtonGroupWrap> | ||
| <AddressBarWrap> | ||
| <AddressBar | ||
| address="loading..." | ||
| icon={ | ||
| <img | ||
| src="https://s3-us-west-2.amazonaws.com/figma-alpha-api/img/76df/255d/0979e7ab815d6ca528f8d9dcd1781acf" | ||
| alt="icon" | ||
| /> | ||
| } | ||
| onRefreshClick={() => console.log("click refresh")} | ||
| /> | ||
| </AddressBarWrap> | ||
| <Trailing> | ||
| <IconsMdiIosShare | ||
| src="https://s3-us-west-2.amazonaws.com/figma-alpha-api/img/da99/bb53/d07b48d9862132562382bf46a02ca50a" | ||
| alt="image of IconsMdiIosShare" | ||
| ></IconsMdiIosShare> | ||
| <IconsMdiAdd | ||
| src="https://s3-us-west-2.amazonaws.com/figma-alpha-api/img/e318/b488/9d87f48c0287cd06fb9565de35a44892" | ||
| alt="image of IconsMdiAdd" | ||
| ></IconsMdiAdd> | ||
| </Trailing> | ||
| </Wrapper> | ||
| ); | ||
| } | ||
| const Wrapper = styled.div` | ||
| display: flex; | ||
| justify-content: flex-start; | ||
| flex-direction: row; | ||
| align-items: center; | ||
| gap: 351px; | ||
| min-height: 100vh; | ||
| background-color: rgba(255, 255, 255, 1); | ||
| box-sizing: border-box; | ||
| padding: 12px 16px; | ||
| `; | ||
| const BrowserNavigationBfButtonGroupWrap = styled.div` | ||
| display: flex; | ||
| justify-content: flex-start; | ||
| align-items: start; | ||
| flex: none; | ||
| gap: 0; | ||
| box-sizing: border-box; | ||
| `; | ||
| const AddressBarWrap = styled.div` | ||
| min-width: min-content; | ||
| width: 100%; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| height: 24px; | ||
| background-color: rgba(216, 215, 216, 1); | ||
| border-radius: 6px; | ||
| position: relative; | ||
| `; | ||
| const Trailing = styled.div` | ||
| width: 52px; | ||
| height: 20px; | ||
| position: relative; | ||
| `; | ||
| const IconsMdiIosShare = styled.img` | ||
| object-fit: cover; | ||
| position: absolute; | ||
| left: 0px; | ||
| top: 0px; | ||
| right: 32px; | ||
| bottom: 0px; | ||
| `; | ||
| const IconsMdiAdd = styled.img` | ||
| object-fit: cover; | ||
| position: absolute; | ||
| left: 32px; | ||
| top: 0px; | ||
| right: 0px; | ||
| bottom: 0px; | ||
| `; | ||
| const Wrap = styled.div` | ||
| width: 100%; | ||
| height: 100%; | ||
| box-sizing: border-box; | ||
| padding: 12px 16px; | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { Meta, Story, Preview, Props } from "@storybook/addon-docs/blocks"; | ||
| import { AddressBar } from "./address-bar"; | ||
| <Meta title="component/address-bar" /> | ||
| # Preview | ||
| <Preview> | ||
| <Story name="based"> | ||
| <div style={{ height: "30px" }}> | ||
| <AddressBar /> | ||
| </div> | ||
| </Story> | ||
| </Preview> | ||
| # Props |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import React, { ReactNode } from "react"; | ||
| import styled from "@emotion/styled"; | ||
| import { RefreshButton } from "./refresh-button"; | ||
| import { MoreHoriz } from "./more-horiz"; | ||
| interface AddressBarProps { | ||
| address: string; | ||
| icon?: ReactNode; | ||
| onRefreshClick: () => void; | ||
| } | ||
| export function AddressBar(props: AddressBarProps) { | ||
| return ( | ||
| <Wrapper> | ||
| <Frame168> | ||
| <RefreshButton onClick={props.onRefreshClick} /> | ||
| <MoreHoriz /> | ||
| </Frame168> | ||
| <Frame167> | ||
| {props.icon} | ||
| <Address>{props.address}</Address> | ||
| </Frame167> | ||
| </Wrapper> | ||
| ); | ||
| } | ||
| const Wrapper = styled.div` | ||
| height: 100%; | ||
| width: 100%; | ||
| background-color: rgba(216, 215, 216, 1); | ||
| border-radius: 6px; | ||
| position: relative; | ||
| `; | ||
| const Frame168 = styled.div` | ||
| display: flex; | ||
| justify-content: center; | ||
| flex-direction: row; | ||
| align-items: center; | ||
| gap: 7px; | ||
| position: absolute; | ||
| top: calc(50% - 8px); | ||
| right: 10px; | ||
| `; | ||
| const Frame167 = styled.div` | ||
| display: flex; | ||
| justify-content: flex-start; | ||
| flex-direction: row; | ||
| align-items: start; | ||
| gap: 6px; | ||
| box-sizing: border-box; | ||
| position: absolute; | ||
| left: calc(50% - 36px); | ||
| top: calc(50% - 7px); | ||
| `; | ||
| const BrowserTabsIndicationPlaceholder = styled.img` | ||
| object-fit: cover; | ||
| `; | ||
| const Address = styled.span` | ||
| color: rgba(0, 0, 0, 1); | ||
| text-overflow: ellipsis; | ||
| font-size: 12px; | ||
| font-family: "Helvetica Neue", sans-serif; | ||
| font-weight: 400; | ||
| line-height: 100%; | ||
| text-align: center; | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { Meta, Story, Preview, Props } from "@storybook/addon-docs/blocks"; | ||
| import { | ||
| BrowserNavigationBfButton, | ||
| BrowserNavigationBfButtonGroup, | ||
| } from "./browser-navigation-bf-button-group"; | ||
| <Meta title="component/browser-navigation-bf-button-group" /> | ||
| # Preview | ||
| <Preview> | ||
| <Story name="forward"> | ||
| <BrowserNavigationBfButton | ||
| hasHistory={true} | ||
| onClick={(isBack) => { | ||
| console.log(isBack); | ||
| }} | ||
| /> | ||
| </Story> | ||
| <Story name="back"> | ||
| <BrowserNavigationBfButton | ||
| isBack={true} | ||
| hasHistory={true} | ||
| onClick={(isBack) => { | ||
| console.log(isBack); | ||
| }} | ||
| /> | ||
| </Story> | ||
| <Story name="no history"> | ||
| <BrowserNavigationBfButton | ||
| isBack={false} | ||
| hasHistory={false} | ||
| onClick={(isBack) => { | ||
| console.log(isBack); | ||
| }} | ||
| /> | ||
| <BrowserNavigationBfButton | ||
| isBack={true} | ||
| hasHistory={false} | ||
| onClick={(isBack) => { | ||
| console.log(isBack); | ||
| }} | ||
| /> | ||
| </Story> | ||
| <Story name="group"> | ||
| <BrowserNavigationBfButtonGroup | ||
| forwardEnable={true} | ||
| backEnable={true} | ||
| handleClick={(isBack) => { | ||
| console.log(isBack); | ||
| }} | ||
| /> | ||
| </Story> | ||
| </Preview> | ||
| # Props |
Uh oh!
There was an error while loading.Please reload this page.