-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update-storybook: Updated dev map pages Fixed storybook styling Switched to a simpler storybook layout Updated storybook
- Loading branch information
Showing
17 changed files
with
186 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { DocsContainer as BaseContainer } from "@storybook/addon-docs"; | ||
import { themes } from "@storybook/theming"; | ||
import h from "@macrostrat/hyper"; | ||
import { useEffect, useState } from "react"; | ||
|
||
export const DocsContainer = ({ children, context }) => { | ||
// Check for body class changes | ||
const [dark, setDark] = useState( | ||
document.body.classList.contains("bp5-dark") | ||
); | ||
|
||
console.log(context); | ||
|
||
useEffect(() => { | ||
const observer = new MutationObserver((mutations) => { | ||
mutations.forEach((mutation) => { | ||
if (mutation.attributeName === "class") { | ||
const dark = document.body.classList.contains("bp5-dark"); | ||
setDark(dark); | ||
} | ||
}); | ||
}); | ||
observer.observe(document.body, { attributes: true }); | ||
return () => observer.disconnect(); | ||
}, []); | ||
|
||
const theme = dark ? themes.dark : themes.light; | ||
|
||
let ctx1 = context; | ||
ctx1.storyById = (id) => { | ||
const storyContext = context.storyById(id); | ||
return { | ||
...storyContext, | ||
parameters: { | ||
...(storyContext?.parameters ?? {}), | ||
docs: { | ||
...(storyContext?.parameters?.docs ?? {}), | ||
theme, | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
return h( | ||
BaseContainer, | ||
{ | ||
theme, | ||
context: ctx1, | ||
}, | ||
children | ||
); | ||
}; |
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,29 @@ | ||
import { dirname, join } from "path"; | ||
import type { StorybookConfig } from "@storybook/react-vite"; | ||
|
||
const config: StorybookConfig = { | ||
// vite | ||
stories: ["../packages/**/*.stories.@(mdx|js|jsx|ts|tsx)"], | ||
addons: [ | ||
getAbsolutePath("@storybook/addon-links"), | ||
getAbsolutePath("@storybook/addon-essentials"), | ||
getAbsolutePath("@storybook/addon-viewport"), | ||
getAbsolutePath("storybook-dark-mode"), | ||
], | ||
core: { | ||
builder: { | ||
name: getAbsolutePath("@storybook/builder-vite"), | ||
options: { | ||
viteConfigPath: require.resolve("../vite.config.ts"), | ||
}, | ||
}, | ||
}, | ||
framework: getAbsolutePath("@storybook/react-vite"), | ||
docs: {}, | ||
}; | ||
|
||
export default config; | ||
|
||
function getAbsolutePath(value: string): any { | ||
return dirname(require.resolve(join(value, "package.json"))); | ||
} |
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 @@ | ||
<meta name="darkreader-lock" /> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<meta name="darkreader-lock" /> | ||
<!--<style>--> | ||
<!-- .sbdocs.sbdocs-wrapper {--> | ||
<!-- background-color: var(--background-color) !important;--> | ||
<!-- }--> | ||
<!--</style>--> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
"private": true, | ||
"repository": "https://github.com/UW-Macrostrat/web-components.git", | ||
"scripts": { | ||
"dev": "yarn workspace @macrostrat/storybook run dev", | ||
"build": "yarn workspace @macrostrat/storybook run build", | ||
"dev": "storybook dev -p 6006 --no-open", | ||
"build": "storybook build --debug", | ||
"status": "tsx scripts/status.ts", | ||
"prepare": "tsx scripts/prepare.ts", | ||
"publish": "tsx scripts/publish.ts" | ||
|
@@ -22,12 +22,27 @@ | |
"@macrostrat/column-components": "./packages/column-components/src" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.18.10", | ||
"@babel/core": "^7.18.6", | ||
"@babel/preset-env": "^7.21.4", | ||
"@babel/preset-typescript": "^7.21.4", | ||
"@blueprintjs/core": "^5.10.2", | ||
"@parcel/packager-ts": "2.12.0", | ||
"@parcel/transformer-sass": "2.12.0", | ||
"@parcel/transformer-typescript-types": "2.12.0", | ||
"@storybook/addon-actions": "^8.3.6", | ||
"@storybook/addon-essentials": "^8.3.6", | ||
"@storybook/addon-links": "^8.3.6", | ||
"@storybook/addon-viewport": "^8.3.6", | ||
"@storybook/builder-vite": "^8.3.6", | ||
"@storybook/components": "^8.3.6", | ||
"@storybook/manager-api": "^8.3.6", | ||
"@storybook/preset-scss": "^1.0.3", | ||
"@storybook/preview-api": "^8.3.6", | ||
"@storybook/react": "^8.3.6", | ||
"@storybook/react-vite": "^8.3.6", | ||
"@storybook/theming": "^8.3.6", | ||
"@types/d3-geo": "^2.0.0", | ||
"@types/geojson": "^7946.0.7", | ||
"axios": "^0.27.2", | ||
"chalk": "^5.0.1", | ||
"concurrently": "^7.2.2", | ||
|
@@ -39,9 +54,15 @@ | |
"marked-terminal": "^7.1.0", | ||
"node-fetch": "^3.2.9", | ||
"prettier": "^2.7.1", | ||
"react": "^18", | ||
"react-dom": "^18", | ||
"sass-embedded": "^1.79.4", | ||
"storybook": "^8.3.6", | ||
"storybook-dark-mode": "^4.0.2", | ||
"tsx": "^4.19.1", | ||
"typescript": "^5.6.2" | ||
"typescript": "^5.6.2", | ||
"underscore": "^1.12.0", | ||
"use-async-effect": "^2.2.1" | ||
}, | ||
"publishedPackages": [ | ||
"ui-components", | ||
|
@@ -53,7 +74,6 @@ | |
], | ||
"workspaces": [ | ||
"packages/*", | ||
"storybook", | ||
"toolchain/*" | ||
], | ||
"packageManager": "[email protected]", | ||
|
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,27 +1,55 @@ | ||
import h from "@macrostrat/hyper"; | ||
import type { Meta } from "@storybook/react"; | ||
import "mapbox-gl/dist/mapbox-gl.css"; | ||
import type { StoryObj } from "@storybook/react"; | ||
|
||
import { DevMapPage } from "../src"; | ||
import Box from "ui-box"; | ||
|
||
const mapboxToken = import.meta.env.VITE_MAPBOX_API_TOKEN; | ||
|
||
function WrappedComponent(props) { | ||
return h(DevMapPage, { ...props, mapboxToken }); | ||
} | ||
|
||
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export | ||
const meta: Meta<typeof DevMapPage> = { | ||
title: "Map interface/Dev map page", | ||
component: DevMapPage, | ||
title: "Map interface/Development map page", | ||
component: WrappedComponent, | ||
parameters: { | ||
layout: "fullscreen", | ||
docs: { | ||
story: { | ||
inline: false, | ||
iframeHeight: 500, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
const mapboxToken = import.meta.env.STORYBOOK_MAPBOX_API_TOKEN; | ||
|
||
export function DevMapPageTest() { | ||
return h( | ||
Box, | ||
{ className: "container", position: "relative", height: 500 }, | ||
h(DevMapPage, { | ||
mapboxToken, | ||
fitViewport: false, | ||
}) | ||
); | ||
} | ||
type Story = StoryObj<typeof DevMapPage>; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
mapPosition: { | ||
camera: { | ||
lat: 0, | ||
lng: 0, | ||
altitude: 50000000, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const ZoomedIn: Story = { | ||
args: { | ||
mapPosition: { | ||
camera: { | ||
lat: 40.7128, | ||
lng: -74.006, | ||
altitude: 300000, | ||
}, | ||
}, | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
} | ||
}, | ||
"include": [ | ||
"./storybook/*.ts", | ||
"./packages/**/src/*.ts", | ||
"./_old/*.ts", | ||
"./packages/**/src/*.ts" | ||
] | ||
} |
Oops, something went wrong.