Code Monkey home page Code Monkey logo

svelte-chota's Introduction

svelte-chota

Svelte UI components based on the super light-weight chota CSS framework.

npm npm

Why chota?

When you decide to use Svelte in your projects, you expect very tiny bundles of code.

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

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

Documentation

Installation

You should install two packages:

  • chota - css framework itself
  • svelte-chota - Svelte components for chota
npm install -D chota svelte-chota

Then open the app root file (usually App.svelte) and add chota import at the top of a <script> block:

<script>
    import 'chota';
    ...
</script>

Usage

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

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

<Input placeholder="What do 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

Any attribute can be passed 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>

svelte-chota's People

Contributors

acim avatar alexxnb avatar ellemenno avatar kindoflew avatar milahu avatar remjx avatar russelgal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

svelte-chota's Issues

Update for sveltekit?

It seems this library is not yet compatible with the new sveltekit (beta). As there is no App.svelte anymore, I tried adding an import 'chota' to $layout.svelte, but the compilation fails:

SyntaxError: Unexpected token ':'                                 [0/5423]
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:
10)               
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at nodeRequire (/tmp/svelte-chota-test2/node_modules/vite/dist/node/ch
unks/dep-60ed4f87.js:69069:17)       
    at ssrImport (/tmp/svelte-chota-test2/node_modules/vite/dist/node/chun
ks/dep-60ed4f87.js:69027:20)         
    at eval (/tmp/svelte-chota-test2/src/routes/$layout.svelte:7:31)

Not sure how to get this working.

Error in Nav component used in Sapper

Nav works fine in Svelte, but in Sapper I get the following error:

I get the following error: TypeError: Cannot read property 'left' of undefined

This is obviously comming from here, so $$props.$$slots seems not to be defined in Sapper. Is there some other way this can be fixed here or shall I raise a new issue on Sapper?

Dropdown icons are broken in Safari

Hey, thanks for making svelte-chota, it’s very handy! I just found this issue while testing it out in Safari:

When using a dropdown component with an icon, iconRight or iconLeft property, the icon will be in the center of the button. This happens in Safari on both macOS and iOS.

Screenshot 2021-11-10 at 02 28 42

Screenshot 2021-11-10 at 02 28 31

(Screenshots are from the official documentation.)

I’m not 100% sure, but it seems to be an issue with svelte-chota rather than chota itself, because chota doesn’t have dropdowns with icons out of the box if I saw that correctly.

Example how to use it in Sapper

I tried to configure this in Sapper but without luck. Can you write a documentation for this, please?

I found out, shall I make PR for this?

Error when using NAV

Hello,
I tried to use NAV in my simple app, but I got this error:

bundles src/main.js → public/build/bundle.js... [!] (plugin svelte) Error: Duplicate slot name "right" in <Nav> src/App.svelte Error: Duplicate slot name "right" in <Nav> at InlineComponentWrapper.set_slot (/home/xxx/progetti/sm_vote/frontend/node_modules/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts:98:10) at new SlotTemplateWrapper (/home/xxxx/progetti/sm_vote/frontend/node_modules/svelte/src/compiler/compile/render_dom/wrappers/SlotTemplate.ts:60:15) at /home/xxxxx/progetti/sm_vote/frontend/node_modules/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts:87:52 at Array.map (<anonymous>) at new InlineComponentWrapper (/home/xxxxx/progetti/sm_vote/frontend/node_modules/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts:87:39) at new FragmentWrapper (/home/xxxx/progetti/sm_vote/frontend/node_modules/svelte/src/compiler/compile/render_dom/wrappers/Fragment.ts:120:21) at new SlotTemplateWrapper (/home/xxxx/progetti/sm_vote/frontend/node_modules/svelte/src/compiler/compile/render_dom/wrappers/SlotTemplate.ts:65:19) at /home/xxxx/progetti/sm_vote/frontend/node_modules/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts:87:52 at Array.map (<anonymous>) at new InlineComponentWrapper (/home/xxxx/progetti/sm_vote/frontend/node_modules/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts:87:39)

Duplicate slot names using Svelte 3.35

Hey!

First of all thanks so much for Svelte Chota!

I thought I'd quickly create something using Svelte Kit this weekend and noticed that there are issues with slots with duplicate names, specifically when I tried to use the Nav component:

[plugin:vite-plugin-svelte] Duplicate slot name "right" in <Nav>

Looks like this issue was picked up here: sveltejs/svelte#6061

I'm going to see if I can work out what will need to change in order to fix it, but thought I'd add the issue for awareness. Also, I may not have the skill required to get anywhere with fixing it!

Need to add correct instructions in Readme.md

The current readme.md file doesn't give the full instructions to use svelte-chota properly.

Edit package.json file and add:
"dependencies": {
"sirv-cli": "^1.0.0",
"postcss": "8.2.5"
}

In rollup.config.js, in css plugin make the following change:
svelte({
compilerOptions: {
// enable run-time checks when not in production
dev: !production
}
, emitCss: true
}),
// we'll extract any component CSS out into
// a separate file - better for performance
//css({ output: 'bundle.css' }),

The current README.md is I feel for an older version of Svelte template.

class names doesn't work as expected

For example,

import { Card } from 'svelte-chota';
<Card style="padding: 20px; width: 500px" class="flex-column-center">
....
</Card>

Here flex-column-center is an external css class. But the css is not reflected in the component.

A11y: A form label must be associated with a control.

I get the following when building the Svelte app sample (sveltejs/template) using svelte-chota:

(!) Plugin svelte: A11y: A form label must be associated with a control.
node_modules/svelte-chota/cmp/Field.svelte
36: <div class:nomessage={!message} use:events {...$$restProps}>
37:   {#if label}
38:     <label>{label}</label>
        ^
39:   {/if}
40:   <p class:grouped class:gapless><slot/></p>

Tabs in nav

Original chota supports Tab and Button in nav, but in chota-svelte only simple links <a> may be used.

Correct documentation text

My english is poor, so the docs text isn't pretty. Necessary to edit the text by somebody who is english native speaker.

Modal bind:open

In component Modal bind works only with variable open
<Modal bind:open>
It will not open, if you change variable name.

Weird errors emerge

Sry for this generic issue, if it's to random just close it xD
Maybe you have an idea what is happening. I have some components that are based of svelte-chota. And they get mounted and unmounted quite often. Sometimes there is this weird thing going on: TypeError: Cannot read property 'c' of undefined at transition_out Now the c of course is some bundler stuff, but the main issue seems to be the transition_out.

// ****/node_modules/svelte-chota/dist/index.js
function transition_out(block, local, detach, callback) {
        if (block && block.o) {
            if (outroing.has(block))
                return;
            outroing.add(block);
            outros.c.push(() => {
                outroing.delete(block);
                if (callback) {
                    if (detach)
                        block.d(1);
                    callback();
                }
            });
            block.o(local);
        }
    }

I've looked through your repo and the only transitions are in the modal, which i neither import or use. Also i don't have any transition going on in my project.

If you have an idea, let me know, other wise just close the issue xD

По поводу установки в Sapper

Подскажите - есть ли способ установить Ваш пакет в Sapper без подключения глобального стиля по примеру ?
При попытке подключить без вышеприведенной строки, стили не подхватываются.

No responsive behavior in nested Rows and Cols

If you create a Row/Col based grid inside a Col, the inner grid won't behave responsive anymore. Cols on the inner grid will always remain side by side and not wrap, although the containing Col from the outer grid is less than 600px in width.

I assume this is more of a CSS problem, but maybe it can be fixed or there's a workaround.

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.