npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svelte-window-system

v0.1.0

Published

<h1 align="center">Welcome to svelte-window-system 👋</h1> <p> <img alt="Version" src="https://img.shields.io/badge/version- (0.1.0)-blue.svg?cacheSeconds=2592000" /> <a href="https://github.com/DonutLaser/svelte-window-system#readme" target="_blank">

Downloads

8

Readme

Simple customizable window system for Svelte

🏠 Homepage

Install

npm install svelte-window-system

Window features

  • Multiple open windows at the same time
  • Draggable
  • Resizable
  • Customizable

Usage

Opening a window

<!-- App.svelte -->
<script>
    import { openWindow } from 'svelte-window-system';
    import MyWindowComponent from 'MyWindowComponent.svelte';

    function openNewWindow() {
        openWindow(MyWindowComponent, { width: 200, height: 400 }, { someProp: 'my window property' });
    }
</script>

<button on:click="{openNewWindow}">Open window</button>
<!-- MyWindowComponent.svelte -->
<script>
    export let someProp = '';
</script>

<div>{someProp}</div>

To open a window, use openWindow(component: any, windowOptions?: WindowOptions, componentProps?: any) function, provide it a component to render inside the window, some options (if you want to change anything beyond the defaults) and an object of component properties that will be passed to the component, rendered inside the window.

Notes:

  • A window will always be rendered as a child of the body

Window options

All of these are optional. | Option | Type | Default value | Description | |---------------------------------|--------------------------|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | width | number | 600 | Initial window width in pixels. | | minWidth | number | 300 | Minimum width of the window. | | maxWidth | number | -1 | Maximum width of the window. Set to -1 to allow the window to be of any width. | | height | number | 500 | Initial window height in pixels. | | minHeight | number | 200 | Minimum height of the window. | | maxHeight | number | -1 | Maximum height of the window. Set to -1 to allow the window to be of any height. | | resizable | boolean | true | Whether the window should be resizable. | | title | string | 'New window' | The title of the window show at the top of the window. | | position | { x: number; y: number } | { x: 0; y: 0 } | The absolute position of the viewport at which the window will be opened. The top-left corner of the window will be placed at this position. Ignored, if openInCenter is true. | | openInCenter | boolean | true | Whether to open the window in the center of the screen. | | alwaysOnTop | boolean | false | Whether to always show the window on top. When there are multiple windows open, this window will always be on top, no matter if it the active window or not. | | preventBodyOverflow | boolean | false | Whether the whole body of the page should overflow when the window is dragged outside the screen. | | animate | boolean | true | Whether the opening and closing of the window should be animated. | | customTitlebarButtons | TitlebarButton[] | [] | By default, there's only a button to close the window in the titlebar, but this property allows you to add custom buttons to the titlebar. | | customTitlebarClass | string | | A class that will style the title bar. Must be defined in global.css. Overrides the default styles completely. | | customInactiveTitlebarClass | string | | A class that will style the title bar when the window is not active. Must be defined in global.css. Overrides the default styles completely. | | customTitlebarButtonClass | string | | A class that will style the title bar buttons. Must be defined in global.css. Overrides the default styles completely. | | customWindowClass | string | | A class that will style the window. Must be defined in global.css. Overrides the default styles completely. |

Component props

You can easily provide the properties for your window component by passing in an object to openWindow function.

const componentProps = {
    propName1: 'propValue1',
    propName2: 'propValue2',
    propName3: { ... },
    propName4: 20,
};

openWindow(component, windowOptions, componentProps);

Adding custom button to the title bar

The system allows you to add custom button to the title bar next to the close button. This can be achieved by providing one or more TitlebarButton objects with windowOptions in a property customTitlebarButtons when opening a window. The style of the button will be the same as the style of close button and if a customTitlebarButtonsClass is specified, the buttons will instead be styled according to the probided class.

TitlebarButton

| Option | Type | Description | |--------------|------------------------------|-------------------------------------| | value | string | Text inside a button | | callback | a function with no arguments | A callback function for the button |

Author

👤 Vidmantas Luneckas

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2021 Vidmantas Luneckas. This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator