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

feat: replace webpack with vite #12

Merged
merged 11 commits into from
Feb 23, 2023
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

4 changes: 0 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/__mocks__
/__tests__
/node_modules
src/**/*
.babelrc
package.json
package-lock.json
webpack.config.js
24 changes: 20 additions & 4 deletions public/example.js → example.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import Crumbs from "./lib/main.js";

document.addEventListener("DOMContentLoaded", () => {
const editCookieButton = document.querySelector(".edit-cookies");
const list = document.querySelector(".accepted-cookies");

const cookies = new Crumbs({
banner: {
title: "We use cookies",
description: "Test",
description: "Test description",
},
days: 365,
domain: "localhost",
Expand All @@ -18,23 +21,36 @@ document.addEventListener("DOMContentLoaded", () => {
identifier: "functional",
required: true,
summary:
"There are a number of cookies we need to use in order for DeployHQ to work properly. These cannot be disabled.",
"There are a number of cookies we need to use in order for out applications to work properly. These cannot be disabled.",
title: "Functional",
},
{
identifier: "analytics",
required: false,
summary:
"We use Google Analytics to measure the performance of our website. We do not store any personal data and your IP address is anonymised. Analytics is disabled in the application itself.",
"We use analytics to measure the performance of our website. We do not store any personal data and your IP address is anonymised.",
title: "Analytics",
},
{
identifier: "live_chat",
required: false,
summary:
"We use a live chat service called Crisp so we can privide support to you where available. Various cookies are stored so chats remain active when you change page.",
"We use a live chat service so we can privide support to you where available. Various cookies are stored so chats remain active when you change page.",
title: "Live Chat",
},
],
});

cookies.on("onSave", (preferences) => {
emptyList();
preferences.forEach((preference) => {
const li = document.createElement("li");
li.textContent = preference;
list.append(li);
});
});

function emptyList() {
list.innerHTML = "";
}
});
Binary file added favicon.ico
Binary file not shown.
22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./lib/styles/main.css" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<title>Crumbs</title>
</head>
<body>
<h1>Crumbs</h1>
<div>
<h2>You are ok with the following cookies being set:</h2>
<ul class="accepted-cookies"></ul>
</div>

<button class="edit-cookies">Edit cookie settings</button>

<script type="module" src="example.js"></script>
</body>
</html>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
49 changes: 44 additions & 5 deletions src/main.css → lib/styles/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

:root {
--crumbs-edit-bg: #f4f4f4;
--crumbs-edit-overlay: rgba(0, 0, 0, 0.4);
Expand All @@ -9,15 +15,29 @@
--crumbs-toggle-switch-focus-border-color: #636363;
}

.crumbs-banner {
bottom: 0;
body {
display: flex;
font-family: "Avenir", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
flex-direction: column;
min-height: 100vh;
}

/* Crumbs styling */

.crumbs-banner {
border: 1px solid;
border-radius: 4px;
bottom: 5%;
display: flex;
justify-content: space-between;
left: 0;
max-width: 1140px;
left: 50%;
margin: auto;
max-width: 1240px;
position: fixed;
width: 100%;
padding: 1rem;
transform: translateX(-50%);
width: 95%;
}

.crumbs-edit {
Expand Down Expand Up @@ -129,6 +149,7 @@

.crumbs-checkbox {
height: 0;
visibility: hidden;
position: absolute;
width: 0;
}
Expand Down Expand Up @@ -230,3 +251,21 @@
flex: 0 1 60%;
}
}

/* Basic styling for developing locally */

h1,
h2 {
margin: 1rem 0;
text-align: center;
}

.accepted-cookies {
list-style: none;
margin-top: 16px;
text-align: center;
}

.edit-cookies {
margin: auto;
}
Loading