Skip to content

Commit

Permalink
feat: responsive design grid (jackyzha0#1354)
Browse files Browse the repository at this point in the history
* Responsive design grid

* Addressed PR feedback

* Bump Quartz version 4.3.1 => 4.4.0

* Moved page-header into center

* Updated docs with new layouts

* Sync updated version number with package-lock

* Table of Content scrollbar auto

* Reset node_modules

* Updated layout images

* Fixed tablet layout

* Finilazed layout images
  • Loading branch information
saberzero1 authored and renyunkang committed Oct 29, 2024
1 parent 7ec9694 commit 31c5b4a
Show file tree
Hide file tree
Showing 17 changed files with 245 additions and 90 deletions.
Binary file removed docs/images/quartz layout.png
Binary file not shown.
Binary file added docs/images/quartz-layout-desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/quartz-layout-mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/quartz-layout-tablet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 24 additions & 3 deletions docs/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ export interface FullPageLayout {
beforeBody: QuartzComponent[] // laid out vertically
pageBody: QuartzComponent // single component
afterBody: QuartzComponent[] // laid out vertically
left: QuartzComponent[] // vertical on desktop, horizontal on mobile
right: QuartzComponent[] // vertical on desktop, horizontal on mobile
left: QuartzComponent[] // vertical on desktop and tablet, horizontal on mobile
right: QuartzComponent[] // vertical on desktop, horizontal on tablet and mobile
footer: QuartzComponent // single component
}
```

These correspond to following parts of the page:

![[quartz layout.png|800]]
| Layout | Preview |
| ------------------------------- | ----------------------------------- |
| Desktop (width > 1200px) | ![[quartz-layout-desktop.png\|800]] |
| Tablet (800px < width < 1200px) | ![[quartz-layout-tablet.png\|800]] |
| Mobile (width < 800px) | ![[quartz-layout-mobile.png\|800]] |

> [!note]
> There are two additional layout fields that are _not_ shown in the above diagram.
Expand All @@ -33,6 +37,23 @@ Quartz **components**, like plugins, can take in additional properties as config

See [a list of all the components](component.md) for all available components along with their configuration options. You can also checkout the guide on [[creating components]] if you're interested in further customizing the behaviour of Quartz.

### Layout breakpoints

Quartz has different layouts depending on the width the screen viewing the website.

The breakpoints for layouts can be configured in `variables.scss`.

- `mobile`: screen width below this size will use mobile layout.
- `desktop`: screen width above this size will use desktop layout.
- Screen width between `mobile` and `desktop` width will use the tablet layout.

```scss
$breakpoints: (
mobile: 800px,
desktop: 1200px,
);
```

### Style

Most meaningful style changes like colour scheme and font can be done simply through the [[configuration#General Configuration|general configuration]] options. However, if you'd like to make more involved style changes, you can do this by writing your own styles. Quartz 4, like Quartz 3, uses [Sass](https://sass-lang.com/guide/) for styling.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@jackyzha0/quartz",
"description": "🌱 publish your digital garden and notes as a website",
"private": true,
"version": "4.3.1",
"version": "4.4.0",
"type": "module",
"author": "jackyzha0 <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion quartz/components/renderPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ export function renderPage(
</div>
</div>
{RightComponent}
<Footer {...componentData} />
</Body>
<Footer {...componentData} />
</div>
</body>
{pageResources.js
Expand Down
55 changes: 43 additions & 12 deletions quartz/components/styles/backlinks.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
@use "../../styles/variables.scss" as *;

.backlinks {
position: relative;
@media all and not ($desktop) {
overflow-y: auto;
display: initial;
&:after {
pointer-events: none;
content: "";
width: 100%;
height: 50px;
position: absolute;
left: 0;
bottom: 0;
opacity: 1;
transition: opacity 0.3s ease;
background: linear-gradient(transparent 0px, var(--light));
}

& > h3 {
font-size: 1rem;
margin: 0;
}
&:has(> .overflow) {
position: unset;
}

& > h3 {
font-size: 1rem;
margin: 0;
}

& > ul {
list-style: none;
padding: 0;
margin: 0.5rem 0;
& > ul {
list-style: none;
padding: 0;
margin: 0.5rem 0;

& > li {
& > a {
background-color: transparent;
& > li {
& > a {
background-color: transparent;
}
}
}

& > .overflow {
max-height: unset;
& > li:last-of-type {
margin-bottom: 0;
}
&:after {
display: none;
}
}
}
Expand Down
25 changes: 21 additions & 4 deletions quartz/components/styles/explorer.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
@use "../../styles/variables.scss" as *;

.explorer {
&.desktop-only {
overflow-y: auto;
}
&:after {
pointer-events: none;
content: "";
width: 100%;
height: 50px;
position: absolute;
left: 0;
bottom: 0;
opacity: 1;
transition: opacity 0.3s ease;
background: linear-gradient(transparent 0px, var(--light));
}
}

button#explorer {
background-color: transparent;
border: none;
Expand Down Expand Up @@ -58,10 +76,6 @@ button#explorer {
visibility: hidden;
}

&.collapsed > .overflow::after {
opacity: 0;
}

& ul {
list-style: none;
margin: 0.08rem 0;
Expand All @@ -76,6 +90,9 @@ button#explorer {
pointer-events: all;
}
}
> #explorer-ul {
max-height: none;
}
}

svg {
Expand Down
2 changes: 1 addition & 1 deletion quartz/components/styles/graph.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
height: 80vh;
width: 80vw;

@media all and (max-width: $fullPageWidth) {
@media all and ($desktop) {
width: 90%;
}
}
Expand Down
2 changes: 1 addition & 1 deletion quartz/components/styles/listPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ li.section-li {
display: grid;
grid-template-columns: fit-content(8em) 3fr 1fr;

@media all and (max-width: $mobileBreakpoint) {
@media all and ($mobile) {
& > .tags {
display: none;
}
Expand Down
2 changes: 1 addition & 1 deletion quartz/components/styles/popover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
opacity 0.3s ease,
visibility 0.3s ease;

@media all and (max-width: $mobileBreakpoint) {
@media all and ($mobile) {
display: none !important;
}
}
Expand Down
10 changes: 6 additions & 4 deletions quartz/components/styles/search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
.search {
min-width: fit-content;
max-width: 14rem;
flex-grow: 0.3;
@media all and ($mobile) {
flex-grow: 0.3;
}

& > .search-button {
background-color: var(--lightgray);
Expand Down Expand Up @@ -62,7 +64,7 @@
margin-left: auto;
margin-right: auto;

@media all and (max-width: $fullPageWidth) {
@media all and ($desktop) {
width: 90%;
}

Expand Down Expand Up @@ -104,7 +106,7 @@
flex: 0 0 min(30%, 450px);
}

@media all and (min-width: $tabletBreakpoint) {
@media all and not ($tablet) {
&[data-preview] {
& .result-card > p.preview {
display: none;
Expand All @@ -130,7 +132,7 @@
border-radius: 5px;
}

@media all and (max-width: $tabletBreakpoint) {
@media all and ($tablet) {
& > #preview-container {
display: none !important;
}
Expand Down
4 changes: 4 additions & 0 deletions quartz/components/styles/toc.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.toc {
overflow-y: auto;
}

button#toc {
background-color: transparent;
border: none;
Expand Down
Loading

0 comments on commit 31c5b4a

Please sign in to comment.