Browse Source

Set up Flowbite and style home page

master
buttercat1791 2 years ago committed by Silberengel
parent
commit
d4a634b7fb
  1. 3
      .vscode/settings.json
  2. 1
      package.json
  3. 3946
      pnpm-lock.yaml
  4. 9
      postcss.config.js
  5. 96
      src/app.css
  6. 5
      src/app.html
  7. 4
      src/app.postcss
  8. 24
      src/lib/Article.svelte
  9. 99
      src/lib/ArticleHeader.svelte
  10. 54
      src/lib/components/Navigation.svelte
  11. 7
      src/routes/+layout.svelte
  12. 2
      src/routes/+page.svelte
  13. 2
      svelte.config.js
  14. 34
      tailwind.config.cjs
  15. 16
      yarn.lock

3
.vscode/settings.json vendored

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
{
"editor.tabSize": 2
}

1
package.json

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
"eslint-plugin-svelte": "^2.35.1",
"flowbite": "^2.2.1",
"flowbite-svelte": "^0.44.22",
"flowbite-svelte-icons": "^1.6.1",
"postcss": "^8.4.33",
"postcss-load-config": "^5.0.2",
"prettier": "^3.2.5",

3946
pnpm-lock.yaml

File diff suppressed because it is too large Load Diff

9
postcss.config.js

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
import tailwindcss from "tailwindcss";
import autoprefixer from "autoprefixer";
export default {
plugins: [
tailwindcss(),
autoprefixer(),
]
};

96
src/app.css

@ -1,3 +1,95 @@ @@ -1,3 +1,95 @@
body {
padding-top: 50px;
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
/* General */
.leather {
@apply bg-primary-1000 dark:bg-primary-0;
}
/* Button */
button.btn-leather.text-white {
@apply text-primary-1000;
}
.btn-leather span svg {
@apply fill-gray-700 hover:fill-primary-400 dark:fill-gray-400 dark:hover:fill-primary-700;
}
.btn-leather.text-xs {
@apply w-7 h-7;
}
.btn-leather.text-xs svg {
@apply w-3 h-3;
}
.btn-leather.text-sm {
@apply w-8 h-8;
}
.btn-leather.text-sm svg {
@apply w-4 h-4;
}
/* Card */
div.card-leather {
@apply bg-primary-1000 dark:bg-primary-0 border-gray-200 has-[:hover]:border-primary-400 dark:border-gray-700 dark:has-[:hover]:border-primary-700;
}
div.card-leather h1,
div.card-leather h2,
div.card-leather h3,
div.card-leather h4,
div.card-leather h5,
div.card-leather h6 {
@apply text-gray-700 hover:text-primary-400 dark:text-gray-400 dark:hover:text-primary-700;
}
/* Modal */
div.modal-leather > div {
@apply bg-primary-1000 dark:bg-primary-0 border-b-[1px] border-gray-700 dark:border-gray-400;
}
div.modal-leather > div > h1,
div.modal-leather > div > h2,
div.modal-leather > div > h3,
div.modal-leather > div > h4,
div.modal-leather > div > h5,
div.modal-leather > div > h6 {
@apply text-gray-700 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-400;
}
div.modal-leather button {
@apply bg-primary-1000 hover:bg-primary-1000 dark:bg-primary-0 dark:hover:bg-primary-0 text-gray-700 hover:text-primary-400 dark:text-gray-400 dark:hover:text-primary-700;
}
/* Navbar */
nav.navbar-leather {
@apply bg-primary-1000 dark:bg-primary-0;
}
nav.navbar-leather svg {
@apply fill-gray-700 hover:fill-primary-400 dark:fill-gray-400 dark:hover:fill-primary-700;
}
nav.navbar-leather h1,
nav.navbar-leather h2,
nav.navbar-leather h3,
nav.navbar-leather h4,
nav.navbar-leather h5,
nav.navbar-leather h6 {
@apply text-gray-700 hover:text-primary-400 dark:text-gray-400 dark:hover:text-primary-700;
}
/* Tooltip */
div.tooltip-leather {
@apply text-gray-700 dark:text-gray-400;
}
/* Unordered list */
.ul-leather li a {
@apply text-gray-700 hover:text-primary-400 dark:text-gray-400 dark:hover:text-primary-700;
}
}

5
src/app.html

@ -5,11 +5,6 @@ @@ -5,11 +5,6 @@
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css"
/>
<html data-theme="dark" />
</head>
<body data-sveltekit-preload-data="hover">

4
src/app.postcss

@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
/* Write your global styles here, in PostCSS syntax */
@tailwind base;
@tailwind components;
@tailwind utilities;

24
src/lib/Article.svelte

@ -3,7 +3,14 @@ @@ -3,7 +3,14 @@
import Toc from '$lib/components/Toc.svelte';
import Notes from '$lib/components/Note.svelte';
import { idList } from '$lib/stores';
import type { NDKEvent } from '@nostr-dev-kit/ndk';
import { page } from '$app/stores';
import { Sidebar, SidebarGroup, SidebarItem, SidebarWrapper } from 'flowbite-svelte';
$: activeUrl = $page.url.pathname;
let events: NDKEvent[] = [];
async function getEvents() {
$idList.forEach(async (id) => {
const event = await $ndk.fetchEvent(id);
@ -13,7 +20,19 @@ @@ -13,7 +20,19 @@
</script>
{#await getEvents() then article}
<div class="article">
<Sidebar {activeUrl}>
<SidebarWrapper>
<SidebarGroup>
{#each events as event}
<SidebarItem
title={event.getMatchingTags('title')[0][1]}
href={nip19.noteEncode(event.id)}
/>
{/each}
</SidebarGroup>
</SidebarWrapper>
</Sidebar>
<!-- <div class="article">
<div class="toc">
<Toc notes={events} />
</div>
@ -21,8 +40,7 @@ @@ -21,8 +40,7 @@
<div class="article-content">
<Notes notes={events} />
</div>
</div>
</div> -->
{/await}
<style>

99
src/lib/ArticleHeader.svelte

@ -1,17 +1,15 @@ @@ -1,17 +1,15 @@
<script lang="ts">
import { ndk } from "$lib/ndk";
// import { nip19 } from "nostr-tools";
import { neventEncode } from "$lib/utils";
import type { NDKEvent } from "@nostr-dev-kit/ndk";
import { standardRelays } from "./consts";
import { idList } from "$lib/stores";
import DefaultButton from "$lib/defaultShareButton.svelte";
import { Card, Button, Modal, Tooltip } from "flowbite-svelte";
import { ClipboardCheckOutline, ClipboardCleanOutline, CodeOutline, ShareNodesOutline } from "flowbite-svelte-icons";
import type { SvelteComponent } from "svelte";
export let event: NDKEvent;
const title: string = JSON.parse(event.content).title;
const href: string = neventEncode(event);
// console.log(event);
// con
// console.log(nip19.neventEncode(event));
const handleSendEvents = () => {
$idList = [];
@ -21,38 +19,65 @@ @@ -21,38 +19,65 @@
$idList = [...$idList, id];
}
};
</script>
<div class="ArticleBox">
<a href="/{href}">
<div class="ArticleHeader" on:click={handleSendEvents}>
<p class="title">{title}</p>
</div>
</a>
<DefaultButton {event} />
</div>
<br />
<style>
.ArticleBox {
/* position: relative; */
display: grid;
grid-template-columns: 3fr 1fr;
border: 1px solid purple;
border-radius: 10px;
border-top-width: 5px;
/* max-width: 100%; */
let eventIdCopied: boolean = false;
function copyEventId() {
console.debug("copyEventID");
const relays: string[] = standardRelays;
const naddr = neventEncode(event, relays);
navigator.clipboard.writeText(naddr);
eventIdCopied = true;
}
.ArticleHeader {
border-radius: 10px;
border-top-width: 5px;
text-align: center;
padding: 30px;
border: 1px solid purple;
let jsonModalOpen: boolean = false;
function viewJson() {
console.debug("viewJSON");
const relays: string[] = standardRelays;
const naddr = neventEncode(event, relays);
jsonModalOpen = true;
}
.title {
color: white;
font-size: 1.5em;
font-weight: bold;
let shareLinkCopied: boolean = false;
function shareNjump() {
const relays: string[] = standardRelays;
const naddr = neventEncode(event, relays);
console.debug(naddr);
navigator.clipboard.writeText(`njump.me/${naddr}`);
shareLinkCopied = true;
}
</style>
</script>
<Card class='ArticleBox card-leather w-80'>
<div class='flex flex-col space-y-4'>
<a href="/{href}" on:click={handleSendEvents}>
<h2>{title}</h2>
</a>
<div class='w-full flex space-x-2 justify-end'>
<Button class='btn-leather' size='xs' on:click={shareNjump}><ShareNodesOutline /></Button>
<Tooltip class='tooltip-leather' type='auto' placement='top' on:show={() => shareLinkCopied = false}>
{#if shareLinkCopied}
<ClipboardCheckOutline />
{:else}
Share via NJump
{/if}
</Tooltip>
<Button class='btn-leather' size='xs' outline on:click={copyEventId}><ClipboardCleanOutline /></Button>
<Tooltip class='tooltip-leather' type='auto' placement='top' on:show={() => eventIdCopied = false}>
{#if eventIdCopied}
<ClipboardCheckOutline />
{:else}
Copy event ID
{/if}
</Tooltip>
<Button class='btn-leather' size='xs' outline on:click={viewJson}><CodeOutline /></Button>
<Tooltip class='tooltip-leather' type='auto' placement='top'>View JSON</Tooltip>
</div>
</div>
<Modal class='modal-leather' title='Event JSON' bind:open={jsonModalOpen} autoclose outsideclose size='sm'>
<code>{JSON.stringify(event.rawEvent())}</code>
</Modal>
</Card>

54
src/lib/components/Navigation.svelte

@ -1,38 +1,24 @@ @@ -1,38 +1,24 @@
<script lang="ts">
import { DarkMode, Navbar, NavLi, NavUl, NavHamburger, NavBrand } from 'flowbite-svelte';
import { HomeSolid } from 'flowbite-svelte-icons';
let className: string;
export { className as class };
</script>
<div class="NavBar">
<a href="./about"> About</a>
<a href="./create"> New Note</a>
<a href="./visualize"> Visualize</a>
<a href="./login" class="login"> Login</a>
<Navbar class={`Navbar navbar-leather ${className}`}>
<div class='flex flex-grow justify-between'>
<NavBrand href='./'>
<h1 class='font-serif'>Alexandria</h1>
</NavBrand>
<!-- TODO: Restyle the dark mode icon. -->
<DarkMode btnClass='btn-leather p-4'/>
</div>
<style>
.login {
float: right;
}
.NavBar {
overflow: hidden;
background-color: #333;
}
.NavBar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.NavBar a:hover {
background-color: #ddd;
color: black;
}
.NavBar a.active {
background-color: #4caf50;
color: white;
}
</style>
<NavHamburger class='btn-leather' />
<NavUl class='ul-leather'>
<NavLi href='./about'>About</NavLi>
<NavLi href='./create'>New Note</NavLi>
<NavLi href='./visualize'>Visualize</NavLi>
<NavLi href='./login'>Login</NavLi>
</NavUl>
</Navbar>

7
src/routes/+layout.svelte

@ -1,15 +1,18 @@ @@ -1,15 +1,18 @@
<script>
import "../app.css";
// import Login from '$lib/login.svelte';
import { tabs, userPublickey } from "$lib/state";
// import {ndk} from '$lib/ndk';
import { browser } from "$app/environment";
import { NDKNip07Signer } from "@nostr-dev-kit/ndk";
import { onMount } from "svelte";
import NavBar from "$lib/components/Navigation.svelte";
import Navigation from "$lib/components/Navigation.svelte";
</script>
<NavBar />
<div class='leather h-full w-full flex flex-col items-center'>
<Navigation class='sticky top-0' />
<slot />
</div>
<style>
</style>

2
src/routes/+page.svelte

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
const eventlist = loadEvents();
</script>
<div class='leather flex flex-col flex-grow-0 space-y-4 overflow-y-auto w-max'>
{#await eventlist}
<p>Loading...</p>
{:then events}
@ -20,3 +21,4 @@ @@ -20,3 +21,4 @@
<ArticleHeader {event} />
{/each}
{/await}
</div>

2
svelte.config.js

@ -5,7 +5,7 @@ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; @@ -5,7 +5,7 @@ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: [vitePreprocess({})],
preprocess: [vitePreprocess()],
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.

34
tailwind.config.cjs

@ -1,17 +1,39 @@ @@ -1,17 +1,39 @@
import flowbite from "flowbite/plugin";
/** @type {import('tailwindcss').Config}*/
const config = {
content: ["./src/**/*.{html,js,svelte,ts}"],
content: [
"./src/**/*.{html,js,svelte,ts}",
"./node_modules/flowbite/**/*.js",
"./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}",
],
theme: {
extend: {},
extend: {
colors: {
primary: {
0: '#110d08',
50: '#231a10',
100: '#342718',
200: '#574229',
300: '#795c39',
400: '#9c7649',
500: '#ad8351',
600: '#b58f62',
700: '#c6a885',
800: '#d6c1a8',
900: '#decdb9',
1000: '#efe6dc',
},
}
},
},
plugins: [
require("@tailwindcss/forms"),
require("@tailwindcss/typography"),
require("flowbite/plugin"),
flowbite(),
],
content: ["./node/modules/flowbite/**/*.js"],
darkMode: 'class',
};
module.exports = config;

16
yarn.lock

@ -161,12 +161,12 @@ @@ -161,12 +161,12 @@
dependencies:
"@noble/hashes" "1.3.2"
"@noble/hashes@^1.3.1", "@noble/hashes@~1.3.1", "@noble/hashes@1.3.1":
"@noble/hashes@^1.3.1", "@noble/hashes@~1.3.0", "@noble/hashes@~1.3.1", "@noble/hashes@1.3.1":
version "1.3.1"
resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz"
integrity sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==
"@noble/hashes@~1.3.0", "@noble/hashes@1.3.2":
"@noble/hashes@1.3.2":
version "1.3.2"
resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz"
integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==
@ -240,21 +240,11 @@ @@ -240,21 +240,11 @@
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.9.6.tgz"
integrity sha512-HUNqM32dGzfBKuaDUBqFB7tP6VMN74eLZ33Q9Y1TBqRDn+qDonkAUyKWwF9BR9unV7QUzffLnz9GrnKvMqC/fw==
"@rollup/rollup-linux-x64-musl@4.9.6":
version "4.9.6"
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.9.6.tgz"
integrity sha512-ch7M+9Tr5R4FK40FHQk8VnML0Szi2KRujUgHXd/HjuH9ifH72GUmw6lStZBo3c3GB82vHa0ZoUfjfcM7JiiMrQ==
"@scure/base@^1.1.1", "@scure/base@1.1.1":
"@scure/base@^1.1.1", "@scure/base@~1.1.0", "@scure/base@1.1.1":
version "1.1.1"
resolved "https://registry.npmjs.org/@scure/base/-/base-1.1.1.tgz"
integrity sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA==
"@scure/base@~1.1.0":
version "1.1.3"
resolved "https://registry.npmjs.org/@scure/base/-/base-1.1.3.tgz"
integrity sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q==
"@scure/bip32@1.3.1":
version "1.3.1"
resolved "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.1.tgz"

Loading…
Cancel
Save