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

Lab notebook components #33

Merged
merged 49 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
32de6d8
Create lab notebook skeleton and single/double column templates
daniel-panhead Sep 27, 2023
b4e9743
Create table of contents sidebar
daniel-panhead Sep 27, 2023
264a8c5
Make navbar sticky
daniel-panhead Sep 27, 2023
56dd53c
Evil DOM hack to populate ToC and scroll on click
daniel-panhead Sep 27, 2023
c120a1c
Added intersection observer to set active header in ToC
daniel-panhead Sep 27, 2023
64edefd
Add window size plugin and refactor navbar responsiveness
daniel-panhead Sep 27, 2023
9496816
Add transition to singlecolumn; only works on expand
daniel-panhead Sep 27, 2023
1858399
Super sketchy hack to transition on collapse
daniel-panhead Sep 27, 2023
88cece9
Refactored columns into Bubble file
daniel-panhead Sep 27, 2023
5f244ba
Fixed bubble expand/collapse (still sketchy)
daniel-panhead Sep 27, 2023
02a807f
Implemented mobile double column component
daniel-panhead Sep 28, 2023
ff25baa
Implemented desktop dropdown for navbar and refactored to use tree
daniel-panhead Sep 28, 2023
41d6116
Implement mobile dropdown navbar
daniel-panhead Sep 28, 2023
8b6a824
Update correct navbar entries and fix mobile navbar nested formatting
daniel-panhead Sep 28, 2023
c0531da
Added alwaysDropdown for SingleColumn; abstracted subheading for Doub…
daniel-panhead Sep 28, 2023
2f5d723
deleted test file
daniel-panhead Sep 28, 2023
5e44481
Prettify all the code
daniel-panhead Sep 28, 2023
3674f1b
Prettified Code!
daniel-panhead Sep 28, 2023
c09abbf
Add hanging indent + documentation
daniel-panhead Sep 28, 2023
3abbd25
Merge branch 'lab-notebook-components' of github.com:biomod2023/biomo…
daniel-panhead Sep 28, 2023
5c60eaf
Prettify all the code again
daniel-panhead Sep 28, 2023
4a59f57
Prettified Code!
daniel-panhead Sep 28, 2023
b94470d
Added basic table component
daniel-panhead Sep 28, 2023
0f8e23f
Added documentation for table
daniel-panhead Sep 28, 2023
de13f52
Merge branch 'lab-notebook-components' of github.com:biomod2023/biomo…
daniel-panhead Sep 28, 2023
1d78202
Prettify all the code again
daniel-panhead Sep 28, 2023
311b801
Prettified Code!
daniel-panhead Sep 28, 2023
41c140b
Finish populating group a
daniel-panhead Sep 28, 2023
9f2b941
Prettified Code!
daniel-panhead Sep 28, 2023
1f095b1
Add scroll dots to mobile double column
daniel-panhead Sep 29, 2023
ce3cb13
Fix type mismatch in DoubleColumn.vue
daniel-panhead Sep 29, 2023
1e8a472
Prettified Code!
daniel-panhead Sep 29, 2023
620b09e
Fix notebook documentation
daniel-panhead Sep 29, 2023
19e1469
Prettified Code!
daniel-panhead Sep 29, 2023
7b5a829
Fix doublecolumn scroll dots
daniel-panhead Sep 29, 2023
298f8b3
Add triplecolumn
daniel-panhead Sep 29, 2023
994b915
Add documentation for triplecolumn and remove test from GroupAView
daniel-panhead Sep 29, 2023
8548112
Prettified Code!
daniel-panhead Sep 29, 2023
737e11d
Hopefully fix scroll dots for good
daniel-panhead Sep 29, 2023
0c7911f
Merge branch 'lab-notebook-components' of github.com:biomod2023/biomo…
daniel-panhead Sep 29, 2023
2a9d7d1
Prettify all the code again
daniel-panhead Sep 29, 2023
313dfe9
Prettified Code!
daniel-panhead Sep 29, 2023
f93609f
Fix notebook docs and ToC spacing
daniel-panhead Sep 29, 2023
126ea78
Change group a results to two column image
daniel-panhead Sep 29, 2023
2894a4c
Prettified Code!
daniel-panhead Sep 29, 2023
b563c28
Improve navbar design
daniel-panhead Sep 29, 2023
71e42ba
Merge branch 'lab-notebook-components' of github.com:biomod2023/biomo…
daniel-panhead Sep 29, 2023
8e2e313
Prettify all the code again
daniel-panhead Sep 29, 2023
07b0710
Prettified Code!
daniel-panhead Sep 29, 2023
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
182 changes: 182 additions & 0 deletions NOTEBOOK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Notebook

You're welcome.

## Usage

All you need to get started is import is the `@/components/lab-notebook/Notebook.vue` file.
The component takes two slots - `title` and `body`. Enter the section title directly into the `title` slot.

For the `body` section, you can populate the content using the `SingleColumn`, `DoubleColumn`, and `TripleColumn` components.
Both components are already designed to be fully responsive - no need to account for resizing.
The table of contents will also automatically populate with the titles provided to these components.

### SingleColumn

The `SingleColumn` component takes a `title`, `body`, and optional centered `graphic` slot.
Directly enter the title text with no tags needed. Fill in the other slots with the body content. If you are writing paragraph blocks, I recommend wrapping all the `<p>` tags with a `<div class="flex flex-col gap-4"></div>`.

```html
<SingleColumn>
<template #title> Title </template>
<template #body>
<p>Body</p>
</template>
<template #graphic>
<!-- optional -->
<img src="path/to/image" />
<p>Caption</p>
</template>
</SingleColumn>
```

The `SingleColumn` component also takes an option `always-dropdown` prop that will force it into the dropdown layout on desktop. This is useful for the References bubble as we can turn this into a collapsible:

```html
<SingleColumn :always-dropdown="true">
<template #title> References </template>
<template #body> Body text </template>
</SingleColumn>
```

To create a hanging indent for references, surround the body with

```html
<div class="pl-6 -indent-6"></div>
```

### DoubleColumn

The `DoubleColumn` component takes a `title`, `left-title`, `left-body`, `right-title`, and `right-body` slot.
Like `SingleColumn`, the titles require no tags, and other slots can be directly populated with just `<p>` tags.

```html
<DoubleColumn>
<template #title> Title </template>

<template #left-title>Subheading 1</template>
<template #left-body>
<p>Left text</p>
</template>

<template #right-title>Subheading 2</template>
<template #right-body>
<p>Right text</p>
</template>
</DoubleColumn>
```

### TripleColumn

Now you're asking for it. FYI, I didn't implement NColumn because I'm not about to figure out how to make arbitrary-arity trees in Vue. This works the same way as `DoubleColumn`, just with a third `mid-` column.

```html
<TripleColumn>
<template #title> Title </template>

<template #left-title>Subheading 1</template>
<template #left-body>
<p>Left text</p>
</template>

<template #mid-title>Subheading 2</template>
<template #mid-body>
<p>Middle text</p>
</template>

<template #right-title>Subheading 3</template>
<template #right-body>
<p>Right text</p>
</template>
</TripleColumn>
```

## CustomTable

Tables in HTML are horrible. This makes it easier. `CustomTable` takes one prop named `tableData` which is shaped like the following:

```javascript
tableData: {
headers: string[]
rowHeaders: string[]
rowsPerRowHeader: number
data: number[][]
}
```

`rowsPerRowHeader` determines how many rows of content each row header should span.
Provide data as a 2D array where each subarray is a row of content.

### Example

```javascript
const tableData = {
headers: [
'Buffer',
'Buffer Concentration (U/mL)',
'Approximate beginning DNase I concentration (ng/mL)',
'Approximate final DNase I concentration (ng/mL)'
],
rowHeaders: ["Manufacturer's Buffer", 'TE', 'HEPES'],
rowsPerRowHeader: 2,
data: [
[0.05, 70, 20],
[0.1, 70, 35],
[0.05, 90, 90],
[0.1, 90, 90],
[0.05, 35, 10],
[0.1, 65, 10]
]
}
```

## Example Template

```html
<script setup lang="ts">
import Notebook from '@/components/lab-notebook/Notebook.vue'
import SingleColumn from '@/components/lab-notebook/SingleColumn.vue'
import DoubleColumn from '@/components/lab-notebook/DoubleColumn.vue'
</script>

<template>
<Notebook>
<template #title>Title</template>
<template #body>
<SingleColumn>
<template #title> Heading 1 </template>
<template #body>
<p>Some body text</p>
<br />
<p>Some more body text</p>
</template>
<template #graphic>
<div class="w-48 h-48 bg-gray-300"></div>
<!-- replace with an <img> -->
<p>Figure 1. blah blah blah</p>
</template>
</SingleColumn>
<DoubleColumn>
<template #title> Heading 2 </template>
<template #left-title>Subheading 1</template>
<template #left-body>
<p>More body text</p>
</template>
<template #right-title>Subheading 2</template>
<template #right-body>
<p>Even more body text</p>
</template>
</DoubleColumn>

<SingleColumn :always-dropdown="true">
<template #title> References </template>
<template #body>
<div class="pl-6 -indent-6">
<p>Blah blah blah</p>
</div>
</template>
</SingleColumn>
</template>
</Notebook>
</template>
```
10 changes: 9 additions & 1 deletion THEME.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ The slate grey color, dark homepage color, and gold color can be accessed with t
</div>
```

The notebook text and bubble background colors can be accessed with the `notebookBg` and `notebookText` keywords:

```html
<div class="bg-notebookBg">
<p class="text-notebookText">Body</p>
</div>
```

## Typography

The Montserrat and Fira Sans fonts have been added to the project. Montserrat has been set as the default font, and Fira Sans can be accessed with `font-title`.

The `text-title` class will give the text a large title font size and semibold font weight. The `text-subtitle` class will give the text a medium font size and normal font weight.
The `text-title` and `text-title-sm` classes will give the text a large title font size and semibold font weight. The `text-subtitle` and `text-subtitle-sm` classes will give the text a medium font size and normal font weight. Use the `-sm` version as the default and the non `-sm` version on the `lg:` breakpoint.

```html
<h1 class="font-title text-title">Title</h1> <!-- This text will be in semibold Fira Sans and large font size -->
Expand Down
11 changes: 10 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"dependencies": {
"oh-vue-icons": "^1.0.0-rc3",
"vue": "^3.3.4",
"vue-router": "^4.2.2"
"vue-router": "^4.2.2",
"vue-window-size": "^2.0.0"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.2.0",
Expand Down
12 changes: 7 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<script setup lang="ts">
import { RouterView } from 'vue-router'
import NavBar from '@/components/NavBar.vue'
import NavBar from '@/components/navbar/NavBar.vue'
import Footer from '@/components/Footer.vue'
</script>

<template>
<NavBar :key="$route.fullPath" />
<RouterView class="mt-24 lg:mt-0"/>
<div class="flex flex-col justify-end grow">
<Footer />
<div class="flex flex-col h-full">
<NavBar :key="$route.fullPath" />
<RouterView class="mt-24 lg:mt-0 bg-slate" />
<div class="flex flex-col justify-end grow">
<Footer />
</div>
</div>
</template>
5 changes: 3 additions & 2 deletions src/assets/main.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;600;700&family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500;600;700&family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400&display=swap');
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
html {
font-family: 'Montserrat', system-ui, sans-serif;
@apply !scroll-smooth;
}
}

Expand Down Expand Up @@ -39,4 +40,4 @@ a {

.ibtn {
@apply bg-[#1e1e1e] hover:bg-[#e2b764] active:bg-[#e2b764] active:opacity-70 text-[#d9d9d9] hover:text-[#1e1e1e] transition-all duration-200 rounded-[16px] font-semibold text-subtitle text-sm py-5 px-6 min-h-[150px] min-w-[150px];
}
}
39 changes: 39 additions & 0 deletions src/components/CustomTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script setup lang="ts">
defineProps<{
tableData: {
headers: string[]
rowHeaders: string[]
rowsPerRowHeader: number
data: number[][]
}
}>()

const border = 'border-notebookText'
</script>

<template>
<table class="table-fixed border-collapse">
<tr class="bg-slate">
<th
v-for="(header, i) in tableData.headers"
:key="i"
:class="'w-1/' + tableData.headers.length"
class="py-2 px-4 text-sm lg:text-base"
>
{{ header }}
</th>
</tr>
<tbody class="bg-dark">
<tr v-for="(row, i) in tableData.data" :key="i">
<th
v-if="i % tableData.rowsPerRowHeader == 0"
:rowspan="tableData.rowsPerRowHeader"
class="text-sm lg:text-base"
>
{{ tableData.rowHeaders[i / tableData.rowsPerRowHeader] }}
</th>
<td v-for="(item, j) in row" :key="j" class="py-1 lg:text-lg">{{ item }}</td>
</tr>
</tbody>
</table>
</template>
Loading