diff options
Diffstat (limited to 'examples/ssr/src')
-rw-r--r-- | examples/ssr/src/components/Container.astro | 3 | ||||
-rw-r--r-- | examples/ssr/src/components/Header.astro | 20 | ||||
-rw-r--r-- | examples/ssr/src/components/ProductListing.astro | 27 | ||||
-rw-r--r-- | examples/ssr/src/components/TextDecorationSkip.astro | 12 | ||||
-rw-r--r-- | examples/ssr/src/pages/cart.astro | 75 | ||||
-rw-r--r-- | examples/ssr/src/pages/index.astro | 54 | ||||
-rw-r--r-- | examples/ssr/src/pages/login.astro | 47 | ||||
-rw-r--r-- | examples/ssr/src/pages/products/[id].astro | 69 |
8 files changed, 157 insertions, 150 deletions
diff --git a/examples/ssr/src/components/Container.astro b/examples/ssr/src/components/Container.astro index f982522b8..3576de90a 100644 --- a/examples/ssr/src/components/Container.astro +++ b/examples/ssr/src/components/Container.astro @@ -1,7 +1,8 @@ --- -const { tag = 'div' } = Astro.props; +const { tag = "div" } = Astro.props; const Tag = tag; --- + <style> .container { width: 1248px; /** TODO: responsive */ diff --git a/examples/ssr/src/components/Header.astro b/examples/ssr/src/components/Header.astro index 426fb4be5..271f73e53 100644 --- a/examples/ssr/src/components/Header.astro +++ b/examples/ssr/src/components/Header.astro @@ -1,13 +1,14 @@ --- -import TextDecorationSkip from './TextDecorationSkip.astro'; -import Cart from './Cart.svelte'; -import { getCart } from '../api'; +import TextDecorationSkip from "./TextDecorationSkip.astro"; +import Cart from "./Cart.svelte"; +import { getCart } from "../api"; const cart = await getCart(Astro.request); const cartCount = cart.items.reduce((sum, item) => sum + item.count, 0); --- + <style> - @import url('https://fonts.googleapis.com/css2?family=Lobster&display=swap'); + @import url("https://fonts.googleapis.com/css2?family=Lobster&display=swap"); header { margin: 1rem 2rem; @@ -17,11 +18,12 @@ const cartCount = cart.items.reduce((sum, item) => sum + item.count, 0); h1 { margin: 0; - font-family: 'Lobster', cursive; + font-family: "Lobster", cursive; color: black; } - a, a:visited { + a, + a:visited { color: inherit; text-decoration: none; } @@ -35,14 +37,12 @@ const cartCount = cart.items.reduce((sum, item) => sum + item.count, 0); margin-right: 1rem; } </style> -<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> +<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" /> <header> <h1><a href="/"><TextDecorationSkip text="Online Store" /></a></h1> <div class="right-pane"> <a href="/login"> - <span class="material-icons"> - login - </span> + <span class="material-icons"> login</span> </a> <Cart client:idle count={cartCount} /> </div> diff --git a/examples/ssr/src/components/ProductListing.astro b/examples/ssr/src/components/ProductListing.astro index c0af5a34c..9a6ed0502 100644 --- a/examples/ssr/src/components/ProductListing.astro +++ b/examples/ssr/src/components/ProductListing.astro @@ -1,6 +1,7 @@ --- const { products } = Astro.props; --- + <style> ul { list-style-type: none; @@ -45,17 +46,17 @@ const { products } = Astro.props; </style> <slot name="title"></slot> <ul> -{products.map(product => ( - <li class="product"> - <a href={`/products/${product.id}`}> - <figure> - <img src={product.image} /> - <figcaption> - <div class="name">{product.name}</div> - <div class="price">${product.price}</div> - </figcaption> - </figure> - </a> - </li> -))} + {products.map((product) => ( + <li class="product"> + <a href={`/products/${product.id}`}> + <figure> + <img src={product.image} /> + <figcaption> + <div class="name">{product.name}</div> + <div class="price">${product.price}</div> + </figcaption> + </figure> + </a> + </li> + ))} </ul> diff --git a/examples/ssr/src/components/TextDecorationSkip.astro b/examples/ssr/src/components/TextDecorationSkip.astro index b35179ea8..191119bf4 100644 --- a/examples/ssr/src/components/TextDecorationSkip.astro +++ b/examples/ssr/src/components/TextDecorationSkip.astro @@ -1,15 +1,17 @@ --- const { text } = Astro.props; -const words = text.split(' '); +const words = text.split(" "); const last = words.length - 1; --- + <style> - span { - text-decoration: underline; - } + span { + text-decoration: underline; + } </style> {words.map((word, i) => ( <Fragment> - <span>{word}</span>{i !== last && (<Fragment> </Fragment>)} + <span>{word}</span> + {i !== last && <Fragment> </Fragment>} </Fragment> ))} diff --git a/examples/ssr/src/pages/cart.astro b/examples/ssr/src/pages/cart.astro index 3277ff2db..2214703f2 100644 --- a/examples/ssr/src/pages/cart.astro +++ b/examples/ssr/src/pages/cart.astro @@ -1,47 +1,50 @@ --- -import Header from '../components/Header.astro'; -import Container from '../components/Container.astro'; -import { getCart } from '../api'; -import { isLoggedIn } from '../models/user'; +import Header from "../components/Header.astro"; +import Container from "../components/Container.astro"; +import { getCart } from "../api"; +import { isLoggedIn } from "../models/user"; -if(!isLoggedIn(Astro.request)) { - return Astro.redirect('/'); +if (!isLoggedIn(Astro.request)) { + return Astro.redirect("/"); } // They must be logged in. -const user = { name: 'test'}; // getUser? +const user = { name: "test" }; // getUser? const cart = await getCart(Astro.request); --- + <html> -<head> - <title>Cart | Online Store</title> - <style> - h1 { - font-size: 36px; - } - </style> -</head> -<body> - <Header /> + <head> + <title>Cart | Online Store</title> + <style> + h1 { + font-size: 36px; + } + </style> + </head> + <body> + <Header /> - <Container tag="main"> - <h1>Cart</h1> - <p>Hi { user.name }! Here are your cart items:</p> - <table> - <thead> - <tr> - <th>Item</th> - <th>Count</th> - </tr> - </thead> - <tbody> - {cart.items.map(item => <tr> - <td>{item.name}</td> - <td>{item.count}</td> - </tr>)} - </tbody> - </table> - </Container> -</body> + <Container tag="main"> + <h1>Cart</h1> + <p>Hi {user.name}! Here are your cart items:</p> + <table> + <thead> + <tr> + <th>Item</th> + <th>Count</th> + </tr> + </thead> + <tbody> + {cart.items.map((item) => ( + <tr> + <td>{item.name}</td> + <td>{item.count}</td> + </tr> + ))} + </tbody> + </table> + </Container> + </body> </html> diff --git a/examples/ssr/src/pages/index.astro b/examples/ssr/src/pages/index.astro index 8eb04ffa6..456de484c 100644 --- a/examples/ssr/src/pages/index.astro +++ b/examples/ssr/src/pages/index.astro @@ -1,36 +1,36 @@ --- -import Header from '../components/Header.astro'; -import Container from '../components/Container.astro'; -import ProductListing from '../components/ProductListing.astro'; -import { getProducts } from '../api'; -import '../styles/common.css'; +import Header from "../components/Header.astro"; +import Container from "../components/Container.astro"; +import ProductListing from "../components/ProductListing.astro"; +import { getProducts } from "../api"; +import "../styles/common.css"; const products = await getProducts(Astro.request); --- -<html> -<head> - <title>Online Store</title> - <style> - h1 { - font-size: 36px; - } - .product-listing-title { - text-align: center; - } +<html> + <head> + <title>Online Store</title> + <style> + h1 { + font-size: 36px; + } - .product-listing { + .product-listing-title { + text-align: center; + } - } - </style> -</head> -<body> - <Header /> + .product-listing { + } + </style> + </head> + <body> + <Header /> - <Container tag="main"> - <ProductListing products={products} class="product-listing"> - <h2 class="product-listing-title" slot="title">Product Listing</h2> - </ProductListing> - </Container> -</body> + <Container tag="main"> + <ProductListing products={products} class="product-listing"> + <h2 class="product-listing-title" slot="title">Product Listing</h2> + </ProductListing> + </Container> + </body> </html> diff --git a/examples/ssr/src/pages/login.astro b/examples/ssr/src/pages/login.astro index b12a82a5e..081aafedf 100644 --- a/examples/ssr/src/pages/login.astro +++ b/examples/ssr/src/pages/login.astro @@ -1,30 +1,31 @@ --- -import Header from '../components/Header.astro'; -import Container from '../components/Container.astro'; +import Header from "../components/Header.astro"; +import Container from "../components/Container.astro"; --- + <html> -<head> - <title>Online Store</title> - <style> - h1 { - font-size: 36px; - } - </style> -</head> -<body> - <Header /> + <head> + <title>Online Store</title> + <style> + h1 { + font-size: 36px; + } + </style> + </head> + <body> + <Header /> - <Container tag="main"> - <h1>Login</h1> - <form action="/login.form" method="POST"> - <label for="name">Name</label> - <input type="text" name="name"> + <Container tag="main"> + <h1>Login</h1> + <form action="/login.form" method="POST"> + <label for="name">Name</label> + <input type="text" name="name" /> - <label for="password">Password</label> - <input type="password" name="password"> + <label for="password">Password</label> + <input type="password" name="password" /> - <input type="submit" value="Submit"> - </form> - </Container> -</body> + <input type="submit" value="Submit" /> + </form> + </Container> + </body> </html> diff --git a/examples/ssr/src/pages/products/[id].astro b/examples/ssr/src/pages/products/[id].astro index f6ac67f82..9ec934aa2 100644 --- a/examples/ssr/src/pages/products/[id].astro +++ b/examples/ssr/src/pages/products/[id].astro @@ -1,46 +1,45 @@ --- -import Header from '../../components/Header.astro'; -import Container from '../../components/Container.astro'; -import AddToCart from '../../components/AddToCart.svelte'; -import { getProduct } from '../../api'; -import '../../styles/common.css'; +import Header from "../../components/Header.astro"; +import Container from "../../components/Container.astro"; +import AddToCart from "../../components/AddToCart.svelte"; +import { getProduct } from "../../api"; +import "../../styles/common.css"; const id = Number(Astro.params.id); const product = await getProduct(Astro.request, id); --- <html lang="en"> -<head> - <title>{product.name} | Online Store</title> - <style> - h2 { - text-align: center; - font-size: 3.5rem; - } + <head> + <title>{product.name} | Online Store</title> + <style> + h2 { + text-align: center; + font-size: 3.5rem; + } - figure { - display: grid; - grid-template-columns: 1fr 1fr; - } + figure { + display: grid; + grid-template-columns: 1fr 1fr; + } - img { - width: 400px; - } - </style> -</head> -<body> - <Header /> - - <Container tag="article"> - <h2>{product.name}</h2> - <figure> - <img src={product.image} /> - <figcaption> - <AddToCart client:idle id={id} name={product.name} /> - <p>Description here...</p> - </figcaption> - </figure> + img { + width: 400px; + } + </style> + </head> + <body> + <Header /> - </Container> -</body> + <Container tag="article"> + <h2>{product.name}</h2> + <figure> + <img src={product.image} /> + <figcaption> + <AddToCart client:idle id={id} name={product.name} /> + <p>Description here...</p> + </figcaption> + </figure> + </Container> + </body> </html> |