Giter Site home page Giter Site logo

replit-makaio's Introduction

template-svelte-composable-component

This repository contains a template for components in Svelte.

Components should have:

The primary component of this repository is LandingPage.svelte

Metadata exports

Quickstart

To build the project:

just setup build

This should output the built project (as-is) to the dist folder, ready to deploy.

Development

Tooling

To develop this project, you'll need the following tooling:

  • just for running tasks (alternative to make)
  • node
  • nvm

Quickstart

Once required tooling has been installed, you can get started developing:

just setup # run once
just devloop

Key files in this project are:

  • index.html: contains the page shell for Svelte to use
  • src/index.ts: contains the initialization code that creates the LandingPage Svelte component
  • src/components/*.svelte: the components in use (including LandingPage itself)

Testing

Tests are written with vitest

How to run the tests

You can run all tests with the following:

just test

You can run tests individually as well:

just test-unit
just test-int
just test-e2e

Reusablility

The LandingPage component is built for composability, which means that it exposes all configuration for the components within it so that it can be easily used the top level.

See index.ts -- it illustrates this concept and serves as a live demonstration:

import {
  default as LandingPage,
  metadata as LandingPageMeta,
} from "./components/LandingPage.svelte";
import { z } from "zod";

// Components *do* rely on TailwindCSS
import "./index.css";

const component = new LandingPage({
  target: document.getElementById("component"),
  props: {
    // The top level component must declare props for the instantiations
    // it contains.
    //
    // For example below, we specify the props that
    // will be piped through to the
    // top navigation (an instance of <NavBar>)
    topnav: {
      brandLinkText: "Brand",
    },

    featureGroup: {
      second: {
        // Textual inputs are fed to svelte-i18n where necessary
        // so they can be paths into the i18n object rather than just strings
        // they should be decided at *the top level*, not the component level
        // (as components could be instantiated multiple times)
        heading: "featureGroup.heading",

        body: "Lots of important information in here.",
        orientation: "image-right",
      },
    },
  } as z.infer<typeof LandingPageMeta.props.zod>,
});

export default component;

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.