Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@benev/slate

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@benev/slate

frontend web stuff

  • 0.0.0-dev.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
630
increased by81.03%
Maintainers
1
Weekly downloads
 
Created
Source


🪨 @benev/slate

🚧 prerelease wip under constructon subject to change

  • frontend ui framework
  • lit compatible, uses lit-html for templating
  • GoldElement is a replacement for LitElement
  • SilverElement is just like GoldElement but for the light dom
  • ShaleView is a sophisticated view class
  • Flat is a state management system
  • Pipe is cool syntax for.. piping
  • Op is a system for showing loading spinners
  • prepare_frontend connects your components and views with app-level context and state management

  1. install slate into your project
npm i @benev/slate
  1. establish a "context" for your app
import {css} from "lit"
import {BaseContext} from "@benev/slate"

export class Context extends BaseContext {

  // state management system
  flat = new Flat()

  // applied to components and views
  theme = css`
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
  `
}
  1. prepare your frontend
export const {component, components, view, views} = prepare_frontend<Context>()
  1. register all your components to the dom
import {register_to_dom} from `@benev/slate`

register_to_dom(components(context, {
  MyElement,
  AnotherElement,
  WhateverElement,
}))

🥇 GoldElement

import {html, css} from "lit"
import {GoldElement} from "@benev/slate"

export const MyComponent = component(context => class extends GoldElement {
  static styles = css``

  #state = context.flat.state({
    count: 0,
  })

  #views = views(context, {
    MyView,
  })

  #increment => () => {
    this.#state.count++
  }

  render() {
    return html`
      <p>count: ${this.#state.count}</p>
      <button @click=${this.#increment}>increment</button>
      ${this.#views.MyView({props: [this.#state.count]})}
    `
  }
})

🥈 SilverElement

it's just like GoldElement, except it's light dom (no shadow dom), and thus it cannot have its own stylesheet (relies on styling from above).


🗿 ShaleView

export const MyView = view(context => class extends ShaleView {
	name = "my-view"
	styles = css``

	render(count: number) {
		return html`<p>${count}</p>`
	}
})
  • views are very similar to components
  • but they are not custom elements
  • they don't need to be registered to the dom
  • views have their own shadow dom
  • they do this thing called auto_exportparts
    • automatically exports shadow parts across many shadow layers
    • it's on by default
    • you just give the view a part, and it will use that part as a prefix to any sub-parts

more utilities with new docs coming soon

  • 🥞 Flatstate docs
  • 🪈 Pipe docs
  • 💫 Op docs

Keywords

FAQs

Package last updated on 05 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc