Skip to content

Commit 50fe40c

Browse files
Bootstrap Customization Instructions
1 parent 537f179 commit 50fe40c

File tree

5 files changed

+69
-8
lines changed

5 files changed

+69
-8
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ __pycache__
55
/.quarto/
66
_docs/
77
.pytest_cache/
8-
.mypy_cache/
8+
.mypy_cache/
9+
node_modules
10+
package-lock.json
11+
package.json

docs/customization.qmd

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ We find that mypy is an enormous time-saver, catching many errors early and grea
5656
- Organization management endpoints: `organization.py`
5757
- Role management endpoints: `role.py`
5858
- Jinja2 templates: `templates/`
59+
- Bootstrap Sass Files: `scss/`
5960
- Static assets: `static/`
6061
- Unit tests: `tests/`
6162
- Test database configuration: `docker-compose.yml`
@@ -100,6 +101,19 @@ To generate the HTML pages to be returned from our GET routes, we use Jinja2 tem
100101

101102
With Jinja2, we can use the `{% block %}` tag to define content blocks, and the `{% extends %}` tag to extend a base template. We can also use the `{% include %}` tag to include a component in a parent template. See the [Jinja2 documentation on template inheritance](https://jinja.palletsprojects.com/en/stable/templates/#template-inheritance) for more details.
102103

104+
### Bootstrap Sass Files
105+
Install Node.js on your local machine if it is not there already.
106+
Install sass, gulp, and gulp-sass on your local machine:
107+
```bash
108+
npm install sass gulp gulp-sass
109+
```
110+
Restart VS Code and press Run Task from the Terminal menu on the gulpfile.js. Choose gulp:default and select your option for output. This automates Sass compilation.
111+
112+
There is already a default styles.scss file in the `scss` folder. Here are customization instructions for Sass files that can be included in `sass`:
113+
[Boostrap Customization with Sass](https://getbootstrap.com/docs/5.3/customize/sass/)
114+
115+
There are a lot of free templates available online, such as on [Start Bootstrap]|[https://startbootstrap.com]
116+
103117
#### Context variables
104118

105119
Context refers to Python variables passed to a template to populate the HTML. In a FastAPI GET route, we can pass context to a template using the `templates.TemplateResponse` method, which takes the request and any context data as arguments. For example:

docs/installation.qmd

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ If you use VSCode with Docker to develop in a container, the following VSCode De
88

99
``` json
1010
{
11-
"name": "Python 3",
12-
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
13-
"postCreateCommand": "sudo apt update && sudo apt install -y python3-dev libpq-dev graphviz && pipx install poetry && poetry install && poetry shell",
14-
"features": {
15-
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
16-
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {}
17-
}
11+
"name": "Python 3",
12+
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bookworm",
13+
"postCreateCommand": "sudo apt update && sudo apt install -y python3-dev libpq-dev graphviz && npm install [email protected] && npm install -g sass && npm install -g gulp && uv venv && uv sync",
14+
"features": {
15+
"ghcr.io/va-h/devcontainers-features/uv:1": {
16+
"version": "latest"
17+
},
18+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
19+
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {},
20+
"ghcr.io/devcontainers/features/node:1": {}
21+
}
1822
}
1923
```
2024

gulpfile.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Sass configuration
2+
var gulp = require('gulp');
3+
var sass = require('gulp-sass')(require('sass'));
4+
5+
gulp.task('sass', function(cb) {
6+
gulp
7+
.src('scss/*.scss')
8+
.pipe(sass())
9+
.pipe(
10+
gulp.dest(function(f) {
11+
return f.base;
12+
})
13+
);
14+
cb();
15+
});
16+
17+
gulp.task(
18+
'default',
19+
gulp.series('sass', function(cb) {
20+
gulp.watch('scss/*.scss', gulp.series('sass'));
21+
cb();
22+
})
23+
);

scss/styles.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
$padding: 6px;
2+
3+
nav {
4+
ul {
5+
margin: 0;
6+
padding: $padding;
7+
list-style: none;
8+
}
9+
10+
li { display: inline-block; }
11+
12+
a {
13+
display: block;
14+
padding: $padding 12px;
15+
text-decoration: none;
16+
}
17+
}

0 commit comments

Comments
 (0)