-
Notifications
You must be signed in to change notification settings - Fork 141
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
card styles #468
Merged
Merged
card styles #468
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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,56 @@ | ||
--- | ||
toc: false | ||
theme: [auto-alt, wide] | ||
--- | ||
|
||
```js | ||
import {resize} from "npm:@observablehq/dash"; | ||
``` | ||
|
||
```js | ||
function AppleStockChart({width}) { | ||
return Plot.plot({ | ||
title: "Apple stock price", | ||
subtitle: "The price of Apple stock continues to climb.", | ||
width, | ||
y: {grid: true}, | ||
marks: [ | ||
Plot.ruleY([0]), | ||
Plot.lineY(aapl, {x: "Date", y: "Close", tip: true}) | ||
] | ||
}); | ||
} | ||
``` | ||
|
||
# Grid test | ||
|
||
<div class="grid grid-cols-4"> | ||
<div class="card"> | ||
<h2>This card has a title</h2> | ||
<h3>And a subtitle, too</h3> | ||
<p>You can put paragraphs of text inside a card, also. But I wouldn’t put too much text inside a card as it’s a bit cramped.</p> | ||
<p>Here’s another paragraph.</p> | ||
</div> | ||
<div class="card"> | ||
<h2>Hello, world!</h2> | ||
</div> | ||
<div class="card"> | ||
<h2>Card three</h2> | ||
</div> | ||
<div class="card"> | ||
<h2>Card four</h2> | ||
</div> | ||
</div> | ||
|
||
<div class="grid grid-cols-2"> | ||
<div class="card">${resize((width) => AppleStockChart({width}))}</div> | ||
<div class="card">${resize((width) => AppleStockChart({width}))}</div> | ||
</div> | ||
|
||
<div class="grid grid-cols-4"> | ||
<div class="card grid-colspan-3">${resize((width) => AppleStockChart({width}))}</div> | ||
<div> | ||
<p>You don’t need to put a border around a grid cell. You can use the grid layout without the <code>card</code> class and it looks like this. You might do this to put some explanatory text adjacent to a chart.</p> | ||
<p>Here lies another paragraph.</p> | ||
</div> | ||
</div> |
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 @@ | ||
.card { | ||
background: var(--theme-background-alt); | ||
border: solid 1px var(--theme-foreground-faintest); | ||
border-radius: 0.75rem; | ||
padding: 1rem; | ||
font: 14px var(--sans-serif); | ||
} | ||
|
||
.card h2, | ||
.card h3 { | ||
font-size: inherit; | ||
} | ||
|
||
.card h2 { | ||
font-weight: 500; | ||
font-size: 15px; | ||
} | ||
|
||
.card h3 { | ||
font-weight: 400; | ||
color: var(--theme-foreground-muted); | ||
} | ||
|
||
.card h2 ~ svg, | ||
.card h3 ~ svg, | ||
.card h2 ~ p, | ||
.card h3 ~ p { | ||
margin-top: 1rem; | ||
} |
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,5 +1,6 @@ | ||
@import url("./global.css"); | ||
@import url("./layout.css"); | ||
@import url("./grid.css"); | ||
@import url("./card.css"); | ||
@import url("./inspector.css"); | ||
@import url("./plot.css"); |
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
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.
I would prefer margin-trim here
but it’s only supported in Safari so far.
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.
good explainer here https://webkit.org/blog/13966/webkit-features-in-safari-16-4/