first commit:
- we have a static astro website under /website. It has the implementation docs of the homepage/gaufre templates, and it handles the few API endpoints (the gaufre js, backgrounds, logos) - we have a vite app under /packages/integration. It has the react components generating the homepage and the gaufre button, and their css. Its used to generate an npm package
This commit is contained in:
218
website/src/pages/api/v1/gaufre.astro
Normal file
218
website/src/pages/api/v1/gaufre.astro
Normal file
@@ -0,0 +1,218 @@
|
||||
---
|
||||
import services from "@/data/services.json"
|
||||
import { Image } from "astro:assets"
|
||||
const logos = import.meta.glob<{ default: ImageMetadata }>("/src/assets/logos/*.svg")
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Services de La Suite numérique</title>
|
||||
<style is:inline>
|
||||
@font-face {
|
||||
font-family: Marianne;
|
||||
src: url("/fonts/Marianne-Regular-subset.woff2") format("woff2");
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Marianne fallback";
|
||||
src: local("Arial");
|
||||
ascent-override: 103.16%;
|
||||
descent-override: 23.35%;
|
||||
line-gap-override: 0%;
|
||||
size-adjust: 109.64%;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
.lasuite-Services {
|
||||
height: 100vh;
|
||||
max-height: 22rem;
|
||||
}
|
||||
|
||||
html {
|
||||
font-size: 100%;
|
||||
font-family: Marianne, "Marianne fallback", BlinkMacSystemFont, "Segoe UI", "Noto Sans",
|
||||
Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0 0 0.5rem;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.fr-sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; /* added line */
|
||||
border: 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.fr-enlarge-link {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.fr-enlarge-link a {
|
||||
background-image: none;
|
||||
outline-width: 0;
|
||||
}
|
||||
|
||||
.fr-enlarge-link a::before {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
outline-offset: 2px;
|
||||
outline-style: inherit;
|
||||
outline-color: inherit;
|
||||
outline-width: 2px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.lasuite-Services {
|
||||
background-color: #01018fcc;
|
||||
padding: 3px;
|
||||
width: 19rem;
|
||||
border-radius: 8px;
|
||||
filter: drop-shadow(0 4px 3px rgb(0 0 0 / 0.07)) drop-shadow(0 2px 2px rgb(0 0 0 / 0.06));
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.lasuite-Services-outer {
|
||||
height: 100%;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.lasuite-Services-inner {
|
||||
border-radius: 2px;
|
||||
background-color: white;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.lasuite-Service {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 1rem 2rem;
|
||||
border-top: 1px solid transparent;
|
||||
border-bottom: 1px solid transparent;
|
||||
}
|
||||
|
||||
.lasuite-Service:hover,
|
||||
.lasuite-Service:focus-within {
|
||||
background-color: #f0f0fa;
|
||||
border-top: 1px solid #8989cd;
|
||||
border-bottom: 1px solid #8989cd;
|
||||
}
|
||||
|
||||
.lasuite-Service-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.lasuite-Service-name {
|
||||
margin-left: 1.5rem;
|
||||
text-decoration: none;
|
||||
color: #161616;
|
||||
}
|
||||
|
||||
.lasuite-Service-name:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.scrollbars {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: #aaa transparent;
|
||||
}
|
||||
.scrollbars::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
}
|
||||
.scrollbars::-webkit-scrollbar-track {
|
||||
background: 0 0;
|
||||
}
|
||||
.scrollbars::-webkit-scrollbar-thumb {
|
||||
background-color: #ddd;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.scrollbars:not(:hover, :focus) {
|
||||
scrollbar-color: transparent transparent;
|
||||
}
|
||||
.scrollbars:not(:hover, :focus):-webkit-scrollbar-thumb {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#lasuite-service-suite-numerique {
|
||||
font-size: 0.85rem;
|
||||
opacity: 0.75;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="lasuite-Services">
|
||||
<div class="lasuite-Services-outer">
|
||||
<h1 class="fr-sr-only">Liste des services de La Suite numérique</h1>
|
||||
<ul class="lasuite-Services-inner scrollbars">
|
||||
{
|
||||
services.map(({ id, name, url }, i) => (
|
||||
<li>
|
||||
<div class="lasuite-Services-item lasuite-Service fr-enlarge-link">
|
||||
<div class="lasuite-Service-icon">
|
||||
<Image
|
||||
src={logos[`/src/assets/logos/${id}.svg`]()}
|
||||
width="40"
|
||||
height="40"
|
||||
alt=""
|
||||
loading="eager"
|
||||
/>
|
||||
</div>
|
||||
<a
|
||||
target="_parent"
|
||||
class="lasuite-Service-name"
|
||||
href={url}
|
||||
id={`lasuite-service-${id}`}
|
||||
{...((i === 0 && { autofocus: true }) || {})}
|
||||
>
|
||||
{name}
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener("keyup", (event) => {
|
||||
if (event.key === "Escape") {
|
||||
window.parent.postMessage("lasuite-close-services-iframe", "*")
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
16
website/src/pages/api/v1/services.json.ts
Normal file
16
website/src/pages/api/v1/services.json.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { APIContext } from "astro"
|
||||
import services from "@/data/services.json"
|
||||
|
||||
export async function GET({ url }: APIContext) {
|
||||
const response = new Response(
|
||||
JSON.stringify(
|
||||
services.map((service) => ({
|
||||
id: service.id,
|
||||
name: service.name,
|
||||
url: new URL(`/services/${service.id}`, url).toString(),
|
||||
})),
|
||||
),
|
||||
)
|
||||
response.headers.set("Content-Type", "application/json")
|
||||
return response
|
||||
}
|
||||
94
website/src/pages/examples/gaufre/html.astro
Normal file
94
website/src/pages/examples/gaufre/html.astro
Normal file
@@ -0,0 +1,94 @@
|
||||
---
|
||||
import gaufreCssUrl from "@gouvfr-lasuite/integration/dist/css/gaufre.css?url"
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Exemple intégration bouton La Gaufre - La Suite numérique</title>
|
||||
<style is:inline>
|
||||
.wrapper {
|
||||
margin: 2rem auto;
|
||||
font-family: sans-serif;
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
}
|
||||
.example {
|
||||
margin: 2rem auto;
|
||||
border: 1px solid #999;
|
||||
padding: 2rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
.example > div {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.example > div > h1 {
|
||||
margin-top: 0;
|
||||
}
|
||||
.example > p {
|
||||
margin-top: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- code à ajouter pour faire marcher le bouton Gaufre -->
|
||||
<!-- ce fichier buildé correspond à @gouvfr-lasuite/integration/dist/css/gaufre.css -->
|
||||
<link rel="stylesheet" href={gaufreCssUrl} />
|
||||
<script
|
||||
is:inline
|
||||
id="lasuite-gaufre-script"
|
||||
async
|
||||
defer
|
||||
src={`${import.meta.env.PUBLIC_LASUITE_API_URL}/api/v1/gaufre.js`}></script>
|
||||
<!-- fin du code à ajouter -->
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<p><a href="/guides/gaufre">Retour à la documentation</a></p>
|
||||
<div class="example">
|
||||
<div>
|
||||
<h1>Test de la Gaufre</h1>
|
||||
|
||||
<!-- code à copier pour faire marcher le bouton Gaufre -->
|
||||
<button
|
||||
type="button"
|
||||
class="lasuite-gaufre-btn lasuite-gaufre-btn--vanilla js-lasuite-gaufre-btn"
|
||||
title="Les services de La Suite numérique"
|
||||
>
|
||||
Les services de La Suite numérique
|
||||
</button>
|
||||
<!-- fin du code à copier -->
|
||||
</div>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac diam a libero posuere
|
||||
ornare facilisis in mi. Nullam eu vulputate augue, in auctor nibh. Praesent ac tempus dui.
|
||||
Integer vel enim non purus facilisis mattis et vel dolor. Aliquam lacinia elit et massa
|
||||
faucibus, at dictum risus ornare. Vivamus ultricies magna et gravida consequat. Donec ac
|
||||
odio finibus, lobortis purus vel, consequat purus. Maecenas convallis vel enim eu
|
||||
malesuada. Vestibulum elementum maximus massa, a porta erat congue quis. Nunc neque quam,
|
||||
euismod et malesuada in, bibendum ac ex. Phasellus felis elit, egestas a convallis nec,
|
||||
malesuada a est. Donec ac urna venenatis lorem aliquet rhoncus in accumsan ipsum.
|
||||
</p>
|
||||
<p>
|
||||
Interdum et malesuada fames ac ante ipsum primis in faucibus. Morbi sed augue elementum,
|
||||
tempus diam in, euismod purus. Fusce interdum, leo nec blandit eleifend, sapien ligula
|
||||
egestas quam, quis aliquam ex turpis ut augue. Nullam a neque consectetur, feugiat eros a,
|
||||
lacinia tortor. Proin imperdiet vehicula justo, eget bibendum tortor gravida a.
|
||||
Pellentesque sit amet fermentum urna. Ut rutrum eros a ligula dapibus pharetra. In
|
||||
porttitor arcu in euismod dictum. Aenean vestibulum mi et dignissim rutrum. Phasellus
|
||||
ultrices ex justo, eu tincidunt metus efficitur non. Curabitur ac lorem ornare, aliquet
|
||||
neque et, tristique elit. Donec quis turpis sodales, interdum massa fermentum, dictum
|
||||
magna.
|
||||
</p>
|
||||
<p>
|
||||
Mauris elit risus, facilisis at magna quis, interdum tempor nulla. Ut ac erat eget tellus
|
||||
ultricies semper. Ut at dictum ante. Lorem ipsum dolor sit amet, consectetur adipiscing
|
||||
elit. Nam placerat lacinia eros ac convallis. Sed ultricies lectus et pharetra aliquet.
|
||||
Vestibulum feugiat pulvinar fermentum. Vivamus imperdiet dapibus ornare. Donec venenatis,
|
||||
lectus id faucibus tempus, sapien urna molestie augue, at egestas enim lectus quis nisi.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user