Giter Club home page Giter Club logo

passages's Introduction

Passages UI

Decentralized story telling. Allowing others to contribute to one narrative story. Each block in the story becomes an NFT.

Installation

Prerequisites

  • Download the latest version of Node and NPM.

Startup

  • Run npm run dev and visit http://localhost:3000/

Tech

Structure and Content

  • ./entry: CSS + JavaScript entry files.
  • ./src: Source files, including components and types.
  • ./tests: All tests live in a flat directory so import statements match elsewhere.

passages's People

Contributors

bholtbholt avatar dependabot[bot] avatar

Watchers

 avatar  avatar

passages's Issues

Convert textarea to rich text (when I figure out what this is suppose to be)

WIP for Rich text. Not anywhere near complete, but has some nice interaction.

Context: I'm getting hung up on the data model but it doesn't matter unless this is being used. For now, a textarea with only paragraphs is probably enough. We can probably run a modification on the data to include the tags if it needs to include paragraph tags etc.

<script lang="ts">
  import type { Passage } from '../src/types';
  import { nanoid } from 'nanoid/non-secure';

  export let latestChapter = 1;
  let chapter = latestChapter;
  let html = 'some content';

  // let showToolbar = false;
  let showToolbar = true;

  function submitPassage() {
    const passage: Passage = { html, chapter, id: nanoid() };
    console.log(passage);
    latestChapter = chapter;
    this.reset();
  }

  function resetPlaceholder() {
    if (this.innerText.trim() === '') this.innerHTML = '';
  }

  import UIButton from './UIButton.svelte';
  import UIButtonSecondary from './UIButtonSecondary.svelte';
  import Chapter from './Chapter.svelte';
</script>

<form class="mt-6" on:submit|preventDefault={submitPassage}>
  {#if chapter !== latestChapter}
    <Chapter>{chapter}</Chapter>
  {/if}

  {#if showToolbar && html}
    <div class="flex space-x-2 xjustify-center px-6">
      <UIButtonSecondary class="py-2 px-2"
        ><svg
          aria-hidden="true"
          focusable="false"
          class="w-3 h-3"
          role="img"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 384 512"
          ><path
            fill="currentColor"
            d="M321.1 242.4C340.1 220.1 352 191.6 352 160c0-70.59-57.42-128-128-128L32 32.01c-17.67 0-32 14.31-32 32s14.33 32 32 32h16v320H32c-17.67 0-32 14.31-32 32s14.33 32 32 32h224c70.58 0 128-57.41 128-128C384 305.3 358.6 264.8 321.1 242.4zM112 96.01H224c35.3 0 64 28.72 64 64s-28.7 64-64 64H112V96.01zM256 416H112v-128H256c35.3 0 64 28.71 64 63.1S291.3 416 256 416z"
          /></svg
        ></UIButtonSecondary
      >
      <UIButtonSecondary class="py-2 px-2"
        ><svg
          aria-hidden="true"
          focusable="false"
          class="w-3 h-3"
          role="img"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 384 512"
          ><path
            fill="currentColor"
            d="M384 64.01c0 17.69-14.31 32-32 32h-58.67l-133.3 320H224c17.69 0 32 14.31 32 32s-14.31 32-32 32H32c-17.69 0-32-14.31-32-32s14.31-32 32-32h58.67l133.3-320H160c-17.69 0-32-14.31-32-32s14.31-32 32-32h192C369.7 32.01 384 46.33 384 64.01z"
          /></svg
        ></UIButtonSecondary
      >
      {#if chapter === latestChapter}
        <UIButtonSecondary class="ml-autox" on:click={() => (chapter = latestChapter + 1)}>
          Start new chapter
        </UIButtonSecondary>
      {/if}
    </div>
  {/if}
  <div
    class="w-full mb-16
      font-serif dark:text-gray-50 indent-6
      focus:outline-none
      text-xl leading-relaxed"
    on:click={() => (showToolbar = true)}
    on:blur={resetPlaceholder}
    bind:innerHTML={html}
    contenteditable="true"
    placeholder="Add your passage to the story…"
  />

  {#if showToolbar && html}
    <div class="flex">
      <UIButton>Add passage</UIButton>
    </div>
  {/if}
</form>

<style>
  [contenteditable]:empty:not(:focus):before {
    content: attr(placeholder);
    color: theme('colors.gray.400');
  }
</style>

Indent based on sibling

/*
  This sibling selector might be released in Tailwind 3
  https://tailwindcss.com/docs/just-in-time-mode#sibling-selector-variants
*/
.peer\:indent-6 + .peer\:indent-6 {
  text-indent: 1.5rem;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.