Coder Social home page Coder Social logo

ankurrsinghal / svelte-legos Goto Github PK

View Code? Open in Web Editor NEW
696.0 11.0 26.0 853 KB

WIP 🚜 A framework for Svelte Utilities πŸ’‘ Current status: 78 utilities.

Home Page: https://svelte-legos.surge.sh

License: MIT License

JavaScript 3.75% CSS 0.56% HTML 0.27% Svelte 34.98% TypeScript 60.43%
svelte svelte-components svelte3 sveltejs sveltekit typescript

svelte-legos's People

Contributors

alanacdz avatar ankurrsinghal avatar ap0nia avatar aslak01 avatar bennymi avatar bobbymannino avatar cunzaizhuyi avatar epavanello avatar jadsn1894 avatar janosh avatar jhthorsen avatar leocaprile avatar nkadebug avatar poesterlin avatar rossrobino avatar sadeghbarati avatar symsmith 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  avatar  avatar  avatar  avatar

svelte-legos's Issues

feat: setup monorepo

Make the lib separate from the docs as the deps of the docs is affecting the libs.

feat: setup discord

It's getting difficult to communicate among contributors, so need a discord server to communicate better.

Enhancement: Rename Actions/Stores

I'm of the opinion that actions should be renamed to drop the "Action" label from imports. This is because the use: syntax indicates that it is an action. Here is also the thread on Twitter discussing the possibility of renaming stores into readable and writable variants. https://twitter.com/ankurpsinghal/status/1637505767757455365?s=46&t=vXFY1pu_gVqC1tnNxYJ_Ow

Below are the different options versus currently.

//Current
import { hoverAction } from "svelte-legos";

//suggested
import { hover } from "svelte-legos";

This gives us

<div use:hoverAction on:hover={handler} />

//versus 

<div use:hover on:hover={handler} />

In terms of stores, appending Store isn't bad but as per the thread maybe explicitly stating readable/writable would be better.

The options are

import { hoverStore } from "svelte-legos";

//versus

//This one seems to make the most sense to me
import { readableHover } from "svelte-legos";

//or maybe

import { hoverReadable } from "svelte-legos";

feat: refactor all DOM logic

notifyAction, alertAction, messageAction and tooltipAction all handles Popper logic separately, need to refactor all this in one place.

feat: emphasize current page in the docs

While going through the different features, I got lost a few times because the current page isn’t highlighted in the menu. Maybe the link could be in bold?

feat: add Prettier config file

Could you add a Prettier config file? My default config is different from yours, it’s making it quite hard to contribute

bug: doc pages reload

When we explore around the docs, clicking pages for different actions and stores the page reloads fully, it should adapt to SPA mode after hydrating.

bug: useWindowScroll doc page

useWindowScroll docs page currently does not scroll enough in x and y direction to show complete working of the hook.

rfc: Introduce 'handlers' and 'transitions' modules

Hi! Came across this package recently and loved the idea. I have a bunch of actions/stores/transitions etc for Svelte I've written over the years and I think this is the perfect place for them!

So, what's the proposal?

I propose we add a new handlers and transitions module(s) to the codebase. For example, we can provide easy and intuitive handlers for common use cases, such as keyboard shortcuts!

Here is an example I've written for a shortcutHandler function:

import type { EventHandler } from "../lib/shared/utils/types";

export type KeyboardShortcut = {
	key: string;
	ctrl?: boolean;
	alt?: boolean;
    description?: string;
	shift?: boolean;
	condition?: boolean;
	fn: () => void;
}

export const shortcutHandler: EventHandler<KeyboardEvent, KeyboardShortcut[]> = (event, shortcuts) => {
	shortcuts.forEach((shortcut) => {
        if (
            event.key === shortcut.key &&
            event.ctrlKey === shortcut.ctrl &&
            event.altKey === shortcut.alt &&
            event.shiftKey === shortcut.shift &&
            (shortcut.condition === undefined || shortcut.condition)
        ) {
            shortcut.fn();
        }
    });
}

and we can consume it like so:

<script lang="ts">
    import { shortcutHandler, type KeyboardShortcut } from '.';
    
    const SHORTCUTS = [
        {
            key: 'a',
            description: 'Add a new item',
            fn: () => alert('Add a new item'),
        },
        {
            key: 'k',
            description: 'Show dialog',
            ctrl: true,
            fn: () => alert('Show dialog'),
        },
        {
            key: 's',
            description: 'Save',
            ctrl: true,
            fn: () => alert('Save'),
        }
    ] satisfies KeyboardShortcut[];
</script>

<svelte:window on:keydown={(e) => shortcutHandler(e, SHORTCUTS)} />

Same thing applies for transitions, for example - here is a "growShrinkTransition":

interface GrowShrinkParams extends TransitionParams {opacity: boolean;}

export const growShrink = (node: Element, params: GrowShrinkParams): TransitionConfig => {
    return {
        delay: params.delay || 0,
        duration: params.duration || 400,
        easing: params.easing || sineInOut,
        css: (t, u) => `
            ${params.opacity ? `opacity: ${t};` : ""}
            width: ${t};
        `
    };
};

and so on.

Let me know what everybody thinks! I also have some ideas for refactoring the frontend (for example, we really should be loading the stores, actions etc in the layout's load function instead of subsequently loading them again in a sub-page's load function and only using the loaded directories files to get the length of the total utilities etc)

bug: usage of actions in docs

Most of the examples in the docs make it seems like you can use the actions on Components...this is simply not permitted in svelte. This can lead inexperienced devs to wonder how they can make their custom button component draggable. I understand it is for simplicity but a bit of markup never killed anyone....I'd say the correct thing to do is update the examples.

suggestion: easy discovery of the docs

Suggestion from Twitter

Have you considered making your docs one long page instead of different pages, like SvelteKit docs? I think it would improve discoverability, especially when checking it out in mobile.
Either way, super cool library, can't wait to try it out!

I'm takling discovery from a user standpoint eg. being able to scroll through all the components to see what the library offers quick and easy 

Link ↓
https://twitter.com/cnrdev/status/1637492355556077570

chore: Add testing

I think adding testing to the actions and stores could be a great idea.

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.