Skip to content

Commit 510af74

Browse files
Scope tailwind preflight styles (#740)
Anywidget loads CSS from the _css attribute to the global scope. A widget most take care not to conflict with any other CSS selectors. The stylesheet from the tailwind preflight, loaded with `@tailwind base`, will conflict with stylesheets from Sphinx themes (#698) or the VScode interactive display (#696). To scope the preflight stylesheet to descendants of a wrapper should fix that. --------- Co-authored-by: Kyle Barron <[email protected]>
1 parent 0ea87cf commit 510af74

File tree

2 files changed

+95
-62
lines changed

2 files changed

+95
-62
lines changed

src/globals.css

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1-
@tailwind base;
1+
div.lonboard {
2+
color: #11181c;
3+
color: hsl(var(--nextui-foreground));
4+
background-color: #fff;
5+
background-color: hsl(var(--nextui-background));
6+
margin: 0;
7+
line-height: 1.5;
8+
-webkit-text-size-adjust: 100%;
9+
tab-size: 4;
10+
font-family:
11+
ui-sans-serif,
12+
system-ui,
13+
-apple-system,
14+
Segoe UI,
15+
Roboto,
16+
Ubuntu,
17+
Cantarell,
18+
Noto Sans,
19+
sans-serif,
20+
"Apple Color Emoji",
21+
"Segoe UI Emoji",
22+
Segoe UI Symbol,
23+
"Noto Color Emoji";
24+
font-feature-settings: normal;
25+
font-variation-settings: normal;
26+
-webkit-tap-highlight-color: transparent;
27+
28+
@tailwind base;
29+
}
30+
231
@tailwind components;
332
@tailwind utilities;

src/index.tsx

+65-61
Original file line numberDiff line numberDiff line change
@@ -213,68 +213,72 @@ function App() {
213213
);
214214

215215
return (
216-
<div
217-
id={`map-${mapId}`}
218-
className="flex"
219-
style={{ height: mapHeight ? `${mapHeight}px` : "24rem" }}
220-
>
221-
<Toolbar />
222-
223-
{showTooltip && highlightedFeature && (
224-
<SidePanel
225-
info={highlightedFeature}
226-
onClose={() => actorRef.send({ type: "Close side panel" })}
227-
/>
228-
)}
229-
<div className="bg-red-800 h-full w-full relative">
230-
<DeckGL
231-
style={{ width: "100%", height: "100%" }}
232-
initialViewState={
233-
["longitude", "latitude", "zoom"].every((key) =>
234-
Object.keys(initialViewState).includes(key),
235-
)
236-
? initialViewState
237-
: DEFAULT_INITIAL_VIEW_STATE
238-
}
239-
controller={true}
240-
layers={
241-
bboxSelectPolygonLayer
242-
? layers.concat(bboxSelectPolygonLayer)
243-
: layers
244-
}
245-
getCursor={() => (isDrawingBBoxSelection ? "crosshair" : "grab")}
246-
pickingRadius={pickingRadius}
247-
onClick={onMapClickHandler}
248-
onHover={onMapHoverHandler}
249-
useDevicePixels={isDefined(useDevicePixels) ? useDevicePixels : true}
250-
// https://deck.gl/docs/api-reference/core/deck#_typedarraymanagerprops
251-
_typedArrayManagerProps={{
252-
overAlloc: 1,
253-
poolSize: 0,
254-
}}
255-
onViewStateChange={(event) => {
256-
const { viewState } = event;
257-
258-
// This condition is necessary to confirm that the viewState is
259-
// of type MapViewState.
260-
if ("latitude" in viewState) {
261-
const { longitude, latitude, zoom, pitch, bearing } = viewState;
262-
setViewState({
263-
longitude,
264-
latitude,
265-
zoom,
266-
pitch,
267-
bearing,
268-
});
216+
<div className="lonboard">
217+
<div
218+
id={`map-${mapId}`}
219+
className="flex"
220+
style={{ height: mapHeight ? `${mapHeight}px` : "24rem" }}
221+
>
222+
<Toolbar />
223+
224+
{showTooltip && highlightedFeature && (
225+
<SidePanel
226+
info={highlightedFeature}
227+
onClose={() => actorRef.send({ type: "Close side panel" })}
228+
/>
229+
)}
230+
<div className="bg-red-800 h-full w-full relative">
231+
<DeckGL
232+
style={{ width: "100%", height: "100%" }}
233+
initialViewState={
234+
["longitude", "latitude", "zoom"].every((key) =>
235+
Object.keys(initialViewState).includes(key),
236+
)
237+
? initialViewState
238+
: DEFAULT_INITIAL_VIEW_STATE
269239
}
270-
}}
271-
parameters={parameters || {}}
272-
>
273-
<Map
274-
mapStyle={mapStyle || DEFAULT_MAP_STYLE}
275-
customAttribution={customAttribution}
276-
></Map>
277-
</DeckGL>
240+
controller={true}
241+
layers={
242+
bboxSelectPolygonLayer
243+
? layers.concat(bboxSelectPolygonLayer)
244+
: layers
245+
}
246+
getCursor={() => (isDrawingBBoxSelection ? "crosshair" : "grab")}
247+
pickingRadius={pickingRadius}
248+
onClick={onMapClickHandler}
249+
onHover={onMapHoverHandler}
250+
useDevicePixels={
251+
isDefined(useDevicePixels) ? useDevicePixels : true
252+
}
253+
// https://deck.gl/docs/api-reference/core/deck#_typedarraymanagerprops
254+
_typedArrayManagerProps={{
255+
overAlloc: 1,
256+
poolSize: 0,
257+
}}
258+
onViewStateChange={(event) => {
259+
const { viewState } = event;
260+
261+
// This condition is necessary to confirm that the viewState is
262+
// of type MapViewState.
263+
if ("latitude" in viewState) {
264+
const { longitude, latitude, zoom, pitch, bearing } = viewState;
265+
setViewState({
266+
longitude,
267+
latitude,
268+
zoom,
269+
pitch,
270+
bearing,
271+
});
272+
}
273+
}}
274+
parameters={parameters || {}}
275+
>
276+
<Map
277+
mapStyle={mapStyle || DEFAULT_MAP_STYLE}
278+
customAttribution={customAttribution}
279+
></Map>
280+
</DeckGL>
281+
</div>
278282
</div>
279283
</div>
280284
);

0 commit comments

Comments
 (0)