Skip to content
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

Scope tailwind preflight styles #740

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/globals.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
@tailwind base;
div.lonboard {
color: #11181c;
color: hsl(var(--nextui-foreground));
background-color: #fff;
background-color: hsl(var(--nextui-background));
margin: 0;
line-height: 1.5;
-webkit-text-size-adjust: 100%;
tab-size: 4;
font-family:
ui-sans-serif,
system-ui,
-apple-system,
Segoe UI,
Roboto,
Ubuntu,
Cantarell,
Noto Sans,
sans-serif,
"Apple Color Emoji",
"Segoe UI Emoji",
Segoe UI Symbol,
"Noto Color Emoji";
font-feature-settings: normal;
font-variation-settings: normal;
-webkit-tap-highlight-color: transparent;
Comment on lines +2 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bjoern-Rapp it didn't notice this when I reviewed yesterday. Could you explain why this was added?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some selectors in the preflight stylesheet targets html, body and :root elements. They become useless when scoped to the div.lonboard wrapper, since there are no html or body elements inside the wrapper. The only alternative then is to copy / duplicate those properties from the resulting stylesheet and apply them directly to the wrapper.


@tailwind base;
}

@tailwind components;
@tailwind utilities;
126 changes: 65 additions & 61 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,68 +213,72 @@ function App() {
);

return (
<div
id={`map-${mapId}`}
className="flex"
style={{ height: mapHeight ? `${mapHeight}px` : "24rem" }}
>
<Toolbar />

{showTooltip && highlightedFeature && (
<SidePanel
info={highlightedFeature}
onClose={() => actorRef.send({ type: "Close side panel" })}
/>
)}
<div className="bg-red-800 h-full w-full relative">
<DeckGL
style={{ width: "100%", height: "100%" }}
initialViewState={
["longitude", "latitude", "zoom"].every((key) =>
Object.keys(initialViewState).includes(key),
)
? initialViewState
: DEFAULT_INITIAL_VIEW_STATE
}
controller={true}
layers={
bboxSelectPolygonLayer
? layers.concat(bboxSelectPolygonLayer)
: layers
}
getCursor={() => (isDrawingBBoxSelection ? "crosshair" : "grab")}
pickingRadius={pickingRadius}
onClick={onMapClickHandler}
onHover={onMapHoverHandler}
useDevicePixels={isDefined(useDevicePixels) ? useDevicePixels : true}
// https://deck.gl/docs/api-reference/core/deck#_typedarraymanagerprops
_typedArrayManagerProps={{
overAlloc: 1,
poolSize: 0,
}}
onViewStateChange={(event) => {
const { viewState } = event;

// This condition is necessary to confirm that the viewState is
// of type MapViewState.
if ("latitude" in viewState) {
const { longitude, latitude, zoom, pitch, bearing } = viewState;
setViewState({
longitude,
latitude,
zoom,
pitch,
bearing,
});
<div className="lonboard">
<div
id={`map-${mapId}`}
className="flex"
style={{ height: mapHeight ? `${mapHeight}px` : "24rem" }}
>
<Toolbar />

{showTooltip && highlightedFeature && (
<SidePanel
info={highlightedFeature}
onClose={() => actorRef.send({ type: "Close side panel" })}
/>
)}
<div className="bg-red-800 h-full w-full relative">
<DeckGL
style={{ width: "100%", height: "100%" }}
initialViewState={
["longitude", "latitude", "zoom"].every((key) =>
Object.keys(initialViewState).includes(key),
)
? initialViewState
: DEFAULT_INITIAL_VIEW_STATE
}
}}
parameters={parameters || {}}
>
<Map
mapStyle={mapStyle || DEFAULT_MAP_STYLE}
customAttribution={customAttribution}
></Map>
</DeckGL>
controller={true}
layers={
bboxSelectPolygonLayer
? layers.concat(bboxSelectPolygonLayer)
: layers
}
getCursor={() => (isDrawingBBoxSelection ? "crosshair" : "grab")}
pickingRadius={pickingRadius}
onClick={onMapClickHandler}
onHover={onMapHoverHandler}
useDevicePixels={
isDefined(useDevicePixels) ? useDevicePixels : true
}
// https://deck.gl/docs/api-reference/core/deck#_typedarraymanagerprops
_typedArrayManagerProps={{
overAlloc: 1,
poolSize: 0,
}}
onViewStateChange={(event) => {
const { viewState } = event;

// This condition is necessary to confirm that the viewState is
// of type MapViewState.
if ("latitude" in viewState) {
const { longitude, latitude, zoom, pitch, bearing } = viewState;
setViewState({
longitude,
latitude,
zoom,
pitch,
bearing,
});
}
}}
parameters={parameters || {}}
>
<Map
mapStyle={mapStyle || DEFAULT_MAP_STYLE}
customAttribution={customAttribution}
></Map>
</DeckGL>
</div>
</div>
</div>
);
Expand Down