svelte-chota

Svelte UI components based on super lightweight chota CSS framework.

Github星跟踪图

svelte-chota

Svelte UI components based on super lightweight chota CSS framework.

npm npm

Why chota?

When you decides to use Svelte in your projects, you expects very tiny bundles of result code.

So the chota is a super light-weight CSS framework, which will add only ~3kb of gzipped code to your CSS bundle.

Svelte-chota is UI kit for easy using chota in your Svelte projects.

Documentation

Installation

There are three ways, how to start using svelte-chota. Recomendended one:

Install packages

You should install three packages:

  • chota - css framework itself
  • svelte-chota - Svelte components for chota
  • rollup-plugin-postcss - allows import css files inside your components and pack it in the bundle.
npm install -D chota svelte-chota rollup-plugin-postcss

Rollup config

Open the rollup.config.js file and edit the config as shown:

...
// import postccs plugin at the top of the file
import postcss from 'rollup-plugin-postcss';
....

const production = !process.env.ROLLUP_WATCH;

export default {
    ...
    plugins: [  
        ...
        svelte({
            ...
            // REPLACE
            //   css: css => {
            //      css.write('public/bundle.css');
            //   }
            // BY:
            emitCss:true
        }),
        // add the postccs plugin
        postcss({
			extract: true,
			minimize: production,
			sourceMap: !production
		}),
        ...
    ]

There we adding PostCSS plugin to pack all component's incapsulated CSS and imported CSS files in a single bundle.css

Importing chota

Now you can import chota in the your App.svelte file:

<script>
    import "chota";
</script>

Note: because you installed PostCSS plugin, now you can import any external css file same way.

Usage

Just import necessary components from the svelte-chota package in your components:

<script>
    import {Input,Button} from 'svelte-chota';
</script>

<Input placeholder="What you want?" /> <Button>Find</Button>

Events handlers

You can use any on:eventname directive with any components:

<script>
    import {Button} from 'svelte-chota';
    let button_text = 'Hover me';
</script>

<Button 
    on:mouseenter={ e => button_text="Don't touch me!" }
    on:mouseleave={ e => button_text="Ok, hover me again" }
>{button_text}</Button>

Attributes

You can pass any attributes to the component, even the class attribute.

<script>
    import {Card} from 'svelte-chota';
</script>

<Card class="is-rounded text-center" style="height:100px; width:100px" title="Hello">
    <h1>Hey!</h1>
</Card>

主要指标

概览
名称与所有者AlexxNB/svelte-chota
主编程语言Svelte
编程语言JavaScript (语言数: 3)
平台
许可证MIT License
所有者活动
创建于2019-09-28 08:43:48
推送于2023-05-12 14:03:04
最后一次提交2021-07-29 14:42:30
发布数0
用户参与
星数287
关注者数7
派生数20
提交数200
已启用问题?
问题数20
打开的问题数5
拉请求数12
打开的拉请求数1
关闭的拉请求数2
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?