Skip to content

Commit

Permalink
Merge pull request #15 from binhtran432k/feature/sass
Browse files Browse the repository at this point in the history
feat: enhance sass
  • Loading branch information
binhtran432k authored Mar 24, 2024
2 parents daf8a77 + 5c051b9 commit a3d0c6c
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 11 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,23 @@ jobs:
dist/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}

- name: Check using Perseus
run: perseus check
- name: Set up Bun
uses: oven-sh/setup-bun@v1

- name: Cache node modules
id: bun-cache
uses: actions/cache@v4
with:
path: |
node_modules/
key: ${{ runner.os }}-node-${{ hashFiles('bun.lockb') }}

- name: Install bun dependencies
if: steps.bun-cache.outputs.cache-hit != 'true'
run: bun install --frozen-lockfile

- name: Check build sass
run: bun sass

- name: Check build static
run: bun check
23 changes: 19 additions & 4 deletions .github/workflows/gh-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,26 @@ jobs:
dist/
key: ${{ runner.os }}-cargo-build-${{ hashFiles('Cargo.lock') }}

- name: Build using Perseus
run: perseus export --release
- name: Set up Bun
uses: oven-sh/setup-bun@v1

- name: Cache node modules
id: bun-cache
uses: actions/cache@v4
with:
path: |
node_modules/
key: ${{ runner.os }}-node-${{ hashFiles('bun.lockb') }}

- name: Install bun dependencies
if: steps.bun-cache.outputs.cache-hit != 'true'
run: bun install --frozen-lockfile

- name: Setup Not Found Page
run: perseus export-error-page -c 404 -o dist/exported/404.html
- name: Generate css from scss
run: bun sass

- name: Build using Perseus
run: bun build

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
Expand Down
50 changes: 47 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
dist/
target/
pkg/
# Build
/dist
/lib
/lib-types
/server
/target
/pkg

# Development
node_modules
*.local

# Cache
.cache
.mf
.rollup.cache
tsconfig.tsbuildinfo

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Editor
.vscode/*
!.vscode/launch.json
!.vscode/*.code-snippets

.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Yarn
.yarn/*
!.yarn/releases

# Static css
/static/styles/*.css
/static/styles/*.css.map
Binary file added bun.lockb
Binary file not shown.
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "binhtran432k.github.io",
"private": true,
"type": "module",
"scripts": {
"dev": "perseus serve -w",
"preview": "perseus export -w",
"check": "perseus check",
"sass": "sass src/sass:static/styles",
"build": "perseus export --release && perseus export-error-page -c 404 -o dist/exported/404.html",
"sass:watch": "sass --watch src/sass:static/styles"
},
"devDependencies": {
"sass": "^1.72.0"
}
}
2 changes: 1 addition & 1 deletion src/error_views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn get_error_page<G: Html>(cx: Scope, title: String, message: String) -> (View<S
},
view! { cx,
// Don't worry, there are much better ways of styling in Perseus!
div(style = "display: flex; flex-direction: column; justify-content: center; align-items: center; height: 95vh;") {
div(class="test") {
h1 { (title) }
p { (message) }
}
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ pub fn main<G: Html>() -> PerseusApp<G> {
meta(charset = "UTF-8")
meta(name = "viewport", content = "width=device-width, initial-scale=1.0")
crate::components::seo::Seo()
// fonts
link (rel="preconnect", href="https://fonts.googleapis.com")
link (rel="preconnect", href="https://fonts.gstatic.com", crossorigin="crossorigin")
link (href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap", rel="stylesheet")
// style
link(rel="stylesheet", href=".perseus/static/styles/base.css")
}
body {
// Quirk: this creates a wrapper `<div>` around the root `<div>` by necessity
Expand Down
17 changes: 17 additions & 0 deletions src/sass/base.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
* {
margin: 0;

&,
&::before,
&::after {
box-sizing: border-box;
}
}

.test {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 95vh;
}
2 changes: 1 addition & 1 deletion src/templates/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use sycamore::prelude::*;
fn index_page<G: Html>(cx: Scope) -> View<G> {
view! { cx,
// Don't worry, there are much better ways of styling in Perseus!
div(style = "display: flex; flex-direction: column; justify-content: center; align-items: center; height: 95vh;") {
div(class="test") {
h1 { "Welcome to Perseus!" }
p {
"This is just an example app. Try changing some code inside "
Expand Down

0 comments on commit a3d0c6c

Please sign in to comment.