Coder Social home page Coder Social logo

sveltestrap's Introduction

sveltestrap

Important Note: This project is now hosted at https://github.com/sveltestrap/sveltestrap

This repo is the legacy repo for Sveltestrap 5 for use with Svelte 3. No new development will happen here.

sveltestrap.js.org docs now point to @sveltestrap/sveltestrap v6, and the new install/import for sveltestrap v6+ is npm install @sveltestrap/sveltestrap (You can still use sveltestrap v5.x via npm install sveltestrap)

We were unable to migrate this repo to the sponsor's org, so please update your imports, stars, bookmarks, etc to https://github.com/sveltestrap/sveltestrap. Our apologies for any confusion. This repo will eventually be archived.


Bootstrap 5 components for Svelte v3

The goal of this library is to provide all Bootstrap 5 components for a Svelte app. Sveltestrap makes it easy to use Bootstrap since there is no need to use Bootstrap component classes, to include Bootstrap's JavaScript, nor depend on jQuery. Sveltestrap is free, open-source software published under the permissive MIT license. This library was inspired by the reactstrap library for React.

To make using Bootstrap themes easier, this library does not embed Bootstrap styles directly and you will need to include Bootstrap 5 CSS in your page.

Demo page


Install

npm install svelte sveltestrap

Usage

You need to include a link to Bootstrap 5 stylesheet in your page - these components do not include or embed any Bootstrap styles automatically.

Either in your HTML layout:

<head>
  <link
    rel="stylesheet"
    href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
  />
</head>

Or from your Svelte app, either:

<svelte:head>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
</svelte:head>

or:

<style>
  @import 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css';
</style>

or alternately, use the Styles component:

<script>
  import { Styles } from 'sveltestrap';
</script>

<Styles />

Then use sveltestrap components in your svelte component:

<script>
  import { Button, Col, Row } from 'sveltestrap';
</script>

<Row>
  <Col>
    <Button color="primary" outline>Hello World!</Button>
  </Col>
</Row>

Note on Icons

If you wish to use the Icon component, you also must include a link to Bootstrap Icon CSS, for example:

<svelte:head>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
</svelte:head>

or:

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
/>

or the Styles component includes the Bootstrap Icon CSS by default:

<script>
  import { Styles } from 'sveltestrap';
</script>
<Styles />

Note on usage with Sapper

If you are using Sveltestrap with Sapper, it's recommended you import the component source directly. Note that this issue does not affect SvelteKit. For example:

<script>
  import { Button, Col, Row } from 'sveltestrap/src';
</script>

<Row>
  <Col>
    <Button color="primary" outline>Hello World!</Button>
  </Col>
</Row>

if you prefer the 'sveltestrap' import, you can move the package to devDependencies block in your package.json so that sapper will parse the es bundle

"devDependencies": {
    "sveltestrap": "*.*.*",
    ...
  },

sveltestrap's People

Contributors

benmccann avatar bestguy avatar blackfenix2 avatar coyotte508 avatar daniacu avatar davidroeca avatar daytonlowell avatar dependabot[bot] avatar dym-sh avatar eddie0329 avatar frederikhors avatar gary-mycase avatar geoffreymugnier avatar gorbulasdev avatar javajudt avatar jlith avatar kaipaysen avatar ladeiko avatar lovasoa avatar masrlinu avatar mohe2015 avatar mopeneko avatar newbyca avatar ojford avatar ondrap avatar renerick avatar rornic avatar thecodejack avatar thomatha avatar ubersan 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sveltestrap's Issues

Label has unused export property

i am using sapper

i get this message when run as dev my saper app :


Label has unused export property 'xs'. If it is for external reference only, please consider using export const xs
18: export { fore as for };
19: export let id = '';
20: export let xs = '';
^
21: export let sm = '';
22: export let md = '';


how remove this message?

do you have sapper install steps?

How to use spacing classes

Hi, I tried to create a container with custom spacing. I noticed the Container component exports className, so I tried this:

<Container className="my-2">
    smth
</Container>

But it doesn't work. Any idea on how I can use spacing classes?

question for Svelte book

@bestguy I opened an issue because I couldn't find another way to contact you. I'm writing the Manning book "Svelte and Sapper in Action". It contains a short section on integration with CSS libraries like Bootstrap. I'm planning to mention your sveltestrap library and include an example of using it.

Would you say it is not possible to use Bootstrap components in a Svelte app or just difficult. If I understand correctly, you reimplemented nearly all of the Bootstrap components as Svelte components which is great! Did you feel that was the only way to make them available in Svelte apps?

Maybe a bug with a modal

I don't know if this problem is with svelte-spa-router or with sveltestrap.

Reproduction here: https://codesandbox.io/s/modern-cache-znqt3

But codesandbox is not the best place for routing issues.
You can download project: "File > Export to Zip".

The problem

Reproduction steps:

  1. Click on "Hello" menu item
  2. Click on button
  3. Modal should appear
  4. Click on the back button of the browser
  5. The problem is "Hello Home" and button are still there (on codesandbox the modal too).

image

util.js: Edge doesn't support property "rest" for objects.

While testing out the library I noticed that on Edge it didn't work, and traced the issue to the function "clean" and in it to "...rest", inside util.js:

  const { children, $$scope, $$slots, ...rest } = $$props; // TODO support keys

`So I changed it to this to get it working:

 const { children, $$scope, $$slots } = $$props;
 const rest = {};
 for (const key of Object.keys($$props)) {
   if (key !== "children" && key !== "$$scope" && key !== "$$slots") {
     rest[key] = $$props[key];
   }
 }
 return rest;

sveltestrap / svelte-routing problem

Problem

svltestrap components don't want to play nicely with svelte-routing navigate function.

When implementating a scenario like:

on:click={() => navigate("/some-url")}

the script crashes with opaque message like:

19:55:56.734 TypeError: os is undefined sveltestrap.es.js:1:392

I've made a repo that replicates the problem here: https://github.com/LaughingBubba/sveltestrap-problem

PS: Luv your work!

Collapse not working

I'm trying to use a Navbar component. I have an issue with the collapse component. The hidden area won't show when I click the NavbarToggler component but the variable isOpen value has changed.

let isOpen = false;
const toggleNavbar = () => (isOpen = !isOpen);

<Navbar dark fixed="top" expand="lg" id="mainNav">
  <div class="container">
    <NavbarBrand href="/">
      <img src="/assets/img/navbar-logo.png" alt="" />
    </NavbarBrand>
    <NavbarToggler on:click={toggleNavbar}>
      Menu
      <i class="fa fa-bars" />
    </NavbarToggler>
    <Collapse isOpen={isOpen} navbar>
      <Nav class="ml-auto text-uppercase" navbar>
        <NavItem>
          <NavLink href="#page-top">Home</NavLink>
        </NavItem>
        <NavItem>
          <NavLink href="#page-top">About Us</NavLink>
        </NavItem>
      </Nav>
    </Collapse>
  </div>
</Navbar>

Page JS weight

Svelte newby here, so please forgive me if this seems like a silly question.
Isn't Svelte supposed to reduce the overall page weight? I'm seeing the sveltestrap page JS weight is many times the size of jQuery/Bootstrap 4 version. What am I missing?

[Navbar] Collapse elements not visible when area is big enough

Collapse elements should remain visible in desktop and only disappear into togglable mode when the screen isn't wide enough
Current state (collapse element link are not visible)
image

Expected( currently only achieved using the toggle in mobile view and then it's possible to see them in desktop):
image

Modal error on close

First of all, thank you for the package, it's being really helpful!

Now, I'm facing a problem with the modals.

I copy & pasted the demo in my app, but when I click on any of the buttons in order to close the modal the following error appears and the modal is not beging closed.

Uncaught (in promise) TypeError: Cannot read property 'c' of undefined
    at transition_out (index.mjs:697)
    at Object.o (App.svelte:4)
    at $s (sveltestrap.es.js:1)
    at Object.o (sveltestrap.es.js:1)
    at $s (sveltestrap.es.js:1)
    at Object.p (sveltestrap.es.js:1)
    at Object.p (sveltestrap.es.js:1)
    at ts (sveltestrap.es.js:1)
    at os (sveltestrap.es.js:1)

If I follow the error in chrome, I'm redirected directly to the following line:

outros.c.push(() => {

Anybody can help me with this, please?

Regards,

Unused export properties...

Some of them...

(!) Plugin svelte: ButtonToolbar has unused export property 'role'. If it is for external reference only, please consider using `export const 'role'`
node_modules\sveltestrap\src\ButtonToolbar.svelte
 6:   export { className as class };
 7:   export let ariaLabel = '';
 8:   export let role = 'toolbar';
                 ^
 9:
10:   const props = clean($$props);
(!) Plugin svelte: ButtonDropdown has unused export property 'group'. If it is for external reference only, please consider using `export const 'group'`
node_modules\sveltestrap\src\ButtonDropdown.svelte
10:   export let disabled = false;
11:   export let dropup = false;
12:   export let group = false;
                 ^
13:   export let inNavbar = false;
14:   export let isOpen = false;
(!) Plugin svelte: CustomInput has unused export property 'multiple'. If it is for external reference only, please consider using `export const 'multiple'`
node_modules\sveltestrap\src\CustomInput.svelte
15:   export let value = '';
16:   export let invalid = false;
17:   export let multiple = false;
                 ^
18:   export let bsSize = '';
19:   export let placeholder = '';
(!) Plugin svelte: Dropdown has unused export property 'disabled'. If it is for external reference only, please consider using `export const 'disabled'`
node_modules\sveltestrap\src\Dropdown.svelte
11:   let className = '';
12:   export { className as class };
13:   export let disabled = false;
                 ^
14:   export let direction = 'down';
15:   export let group = false;
(!) Plugin svelte: DropdownMenu has unused export property 'flip'. If it is for external reference only, please consider using `export const 'flip'`
node_modules\sveltestrap\src\DropdownMenu.svelte
 9:   export { className as class };
10:   export let right = false;
11:   export let flip = true;
                 ^
12:   export let persist = false;
13:
(!) Plugin svelte: DropdownMenu has unused export property 'persist'. If it is for external reference only, please consider using `export const 'persist'`
node_modules\sveltestrap\src\DropdownMenu.svelte
10:   export let right = false;
11:   export let flip = true;
12:   export let persist = false;
                 ^
13:
14:   const props = clean($$props);
(!) Plugin svelte: DropdownToggle has unused export property 'ariaHaspopup'. If it is for external reference only, please consider using `export const 'ariaHaspopup'`
node_modules\sveltestrap\src\DropdownToggle.svelte
13:   export let color = 'secondary';
14:   export let disabled = false;
15:   export let ariaHaspopup = false;
                 ^
16:   export let ariaLabel = 'Toggle Dropdown';
17:   export let split = false;
(!) Plugin svelte: Label has unused export property 'xs'. If it is for external reference only, please consider using `export const 'xs'`
node_modules\sveltestrap\src\Label.svelte
18:   export { fore as for };
19:   export let id = '';
20:   export let xs = '';
                 ^
21:   export let sm = '';
22:   export let md = '';
(!) Plugin svelte: Label has unused export property 'sm'. If it is for external reference only, please consider using `export const 'sm'`
node_modules\sveltestrap\src\Label.svelte
19:   export let id = '';
20:   export let xs = '';
21:   export let sm = '';
                 ^
22:   export let md = '';
23:   export let lg = '';
(!) Plugin svelte: Label has unused export property 'md'. If it is for external reference only, please consider using `export const 'md'`
node_modules\sveltestrap\src\Label.svelte
20:   export let xs = '';
21:   export let sm = '';
22:   export let md = '';
                 ^
23:   export let lg = '';
24:   export let xl = '';
(!) Plugin svelte: Label has unused export property 'lg'. If it is for external reference only, please consider using `export const 'lg'`
node_modules\sveltestrap\src\Label.svelte
21:   export let sm = '';
22:   export let md = '';
23:   export let lg = '';
                 ^
24:   export let xl = '';
25:   export let widths = colWidths;
(!) Plugin svelte: Label has unused export property 'xl'. If it is for external reference only, please consider using `export const 'xl'`
node_modules\sveltestrap\src\Label.svelte
22:   export let md = '';
23:   export let lg = '';
24:   export let xl = '';
                 ^
25:   export let widths = colWidths;
26:
(!) Plugin svelte: Label has unused export property 'widths'. If it is for external reference only, please consider using `export const 'widths'`
node_modules\sveltestrap\src\Label.svelte
23:   export let lg = '';
24:   export let xl = '';
25:   export let widths = colWidths;
                 ^
26:
27:   const colClasses = [];
(!) Plugin svelte: Modal has unused export property 'keyboard'. If it is for external reference only, please consider using `export const 'keyboard'`
node_modules\sveltestrap\src\Modal.svelte
24:   export let size = '';
25:   export let toggle = undefined;
26:   export let keyboard = true;
                 ^
27:   export let role = 'dialog';
28:   export let labelledBy = '';
(!) Plugin svelte: Modal has unused export property 'role'. If it is for external reference only, please consider using `export const 'role'`
node_modules\sveltestrap\src\Modal.svelte
25:   export let toggle = undefined;
26:   export let keyboard = true;
27:   export let role = 'dialog';
                 ^
28:   export let labelledBy = '';
29:   export let backdrop = true;
(!) Plugin svelte: Modal has unused export property 'labelledBy'. If it is for external reference only, please consider using `export const 'labelledBy'`
node_modules\sveltestrap\src\Modal.svelte
26:   export let keyboard = true;
27:   export let role = 'dialog';
28:   export let labelledBy = '';
                 ^
29:   export let backdrop = true;
30:   export let onEnter = undefined;
(!) Plugin svelte: Modal has unused export property 'onOpened'. If it is for external reference only, please consider using `export const 'onOpened'`
node_modules\sveltestrap\src\Modal.svelte
30:   export let onEnter = undefined;
31:   export let onExit = undefined;
32:   export let onOpened = noop;
                 ^
33:   export let onClosed = noop;
34:   export let wrapClassName = '';
(!) Plugin svelte: Modal has unused export property 'external'. If it is for external reference only, please consider using `export const 'external'`
node_modules\sveltestrap\src\Modal.svelte
36:   export let backdropClassName = '';
37:   export let contentClassName = '';
38:   export let external = undefined;
                 ^
39:   export let zIndex = 1050;
40:   export let backdropTransition = '';
(!) Plugin svelte: Modal has unused export property 'backdropTransition'. If it is for external reference only, please consider using `export const 'backdropTransition'`
node_modules\sveltestrap\src\Modal.svelte
38:   export let external = undefined;
39:   export let zIndex = 1050;
40:   export let backdropTransition = '';
                 ^
41:   export let modalTransition = '';
42:   export let unmountOnClose = true;
(!) Plugin svelte: Modal has unused export property 'modalTransition'. If it is for external reference only, please consider using `export const 'modalTransition'`
node_modules\sveltestrap\src\Modal.svelte
39:   export let zIndex = 1050;
40:   export let backdropTransition = '';
41:   export let modalTransition = '';
                 ^
42:   export let unmountOnClose = true;
43:   export let returnFocusAfterClose = true;
(!) Plugin svelte: Navbar has unused export property 'full'. If it is for external reference only, please consider using `export const 'full'`
node_modules\sveltestrap\src\Navbar.svelte
 7:   export let light = false;
 8:   export let dark = false;
 9:   export let full = false;
                 ^
10:   export let fixed = '';
11:   export let sticky = '';
(!) Plugin svelte: Navbar has unused export property 'role'. If it is for external reference only, please consider using `export const 'role'`
node_modules\sveltestrap\src\Navbar.svelte
11:   export let sticky = '';
12:   export let color = '';
13:   export let role = '';
                 ^
14:   export let expand = false;
15:
(!) Plugin svelte: NavbarToggler has unused export property 'type'. If it is for external reference only, please consider using `export const 'type'`
node_modules\sveltestrap\src\NavbarToggler.svelte
 7:   let className = '';
 8:   export {className as class};
 9:   export let type = 'button';
                 ^
10:
11:   const props = clean($$props);
(!) Plugin svelte: Toast has unused export property 'fade'. If it is for external reference only, please consider using `export const 'fade'`
node_modules\sveltestrap\src\Toast.svelte
 6:   let className = '';
 7:   export { className as class };
 8:   export let fade = true;
                 ^
 9:   export let isOpen = true;
10:
(!) Plugin svelte: TabPane has unused export property 'activeTab'. If it is for external reference only, please consider using `export const 'activeTab'`
node_modules\sveltestrap\src\TabPane.svelte
 6:   let className = '';
 7:   export { className as class };
 8:   export let activeTab;
                 ^
 9:   export let tabId;
10:
(!) Plugin svelte: UncontrolledCollapse has unused export property 'navbar'. If it is for external reference only, please consider using `export const 'navbar'`
node_modules\sveltestrap\src\UncontrolledCollapse.svelte
11:   let className = '';
12:   export { className as class };
13:   export let navbar = false;
                 ^
14:   export let defaultOpen = false;
15:   export let toggler;
(!) Plugin svelte: UncontrolledFade has unused export property 'navbar'. If it is for external reference only, please consider using `export const 'navbar'`
node_modules\sveltestrap\src\UncontrolledFade.svelte
11:   let className = '';
12:   export { className as class };
13:   export let navbar = false;
                 ^
14:   export let defaultOpen = false;
15:   export let toggler;
(!) Plugin svelte: UncontrolledButtonDropdown has unused export property 'direction'. If it is for external reference only, please consider using `export const 'direction'`
node_modules\sveltestrap\src\UncontrolledButtonDropdown.svelte
 6:   export { className as class };
 7:   export let disabled = false;
 8:   export let direction = 'down';
                 ^
 9:   export let group = false;
10:   export let nav = false;
(!) Plugin svelte: UncontrolledButtonDropdown has unused export property 'toggle'. If it is for external reference only, please consider using `export const 'toggle'`
node_modules\sveltestrap\src\UncontrolledButtonDropdown.svelte
12:   export let addonType = false;
13:   export let size = '';
14:   export let toggle = undefined;
                 ^
15:   export let inNavbar = false;
16:   export let setActiveFromChild = false;
(!) Plugin svelte: UncontrolledDropdown has unused export property 'toggle'. If it is for external reference only, please consider using `export const 'toggle'`
node_modules\sveltestrap\src\UncontrolledDropdown.svelte
13:   export let addonType = false;
14:   export let size = '';
15:   export let toggle = undefined;
                 ^
16:   export let inNavbar = false;
17:   export let setActiveFromChild = false;
...

Svelte v3 compatibility

Now that v3 of Svelte is out, are you interested in upgrading this library to be compatible?

I've started a fork to work on updating the components to be compatible with v3.

Bind value on Input type=select

This causes error when shown:

<Input
   type="select"
   name="content_type"
   id="content_type"
   bind:value={content_type}
   placeholder="password">
   <Option value="video">Video</Option>
   <Option value="picture">Picture</Option>
</Input>

Spread props break inputs

(Or at least the docs, investigate.)

3.1.0 was unpublished from npm, but issue still effects master.

Typescript types support?

I would like to use this lib in my svelte + typescript(preprocess) project, yet i'm having trouble importing it due to lack of types. Can someone provide @types/sveltestrap any soon? <3

Support SSR

I have created a simple Svelte starter for Meteor, and it was reported that sveltestrap doesn't work with my SSR solution. I believe this is because your component is published in a pre-compiled state, instead of providing raw source and exposing that through a svelte key in package.json as is demonstrated in sveltejs/component-template.

Svelte's SSR support works by using an entirely different compiler for server rendering, and would seem to require raw source in order to function properly.

No bind on switch

<CustomInput
     type="switch"
     id="blabla"
     checked={isAllowedNotification}
     disabled
/>

it works but, can't be use bind:checked.

Spread event handlers

Looks like we don't support many props and event handlers unless specifically added to interface.

I need to catch up with Svelte 3 but doesn't look like it supports spread props ala React: {...props}. May need to add them all individually, although this Svelte PR seems to add on:* event support: sveltejs/svelte#3349

Nested async components error when switching components

Hello, please take a look at the following two comments.
sveltejs/svelte#3448 (comment)
sveltejs/svelte#3448 (comment)

I think as mentioned here:

In the end @halfnelson came up with a solution where the pre-built component should declare at least the svelte/internal imports as globals (rollup) or externals (webpack).
You can see that comment and my comment afterwards stating what I did here: #3671 (comment)
If this is the problem that's being discussed here then it would seem that projects distributing pre-built Svelte components should set their bundles to be built expecting at least the svelte/internal import to be provided as a global somewhere.

I guess that sveltestrap case is to expect global svelte/internal import npm install --save svelte sveltestrap.

Correct docs build

It's in weird state after Svelte 3 merge, requires manually updating docs folder...

Input type submit is missing

The input type submit is not listed in the if-statement that checks the type it will therefor end up render nothing.

Is there any other way to submit forms?

error under "Svelte DevTools"

While trying 1st sample from https://bestguy.github.io/sveltestrap/?path=/story/components--navbar
under "Svelte DevTools" (https://chrome.google.com/webstore/detail/svelte-devtools/ckolcbmkjpjmangdbmnkpjigpkddpogn?hl=en-US)
I get the error below on console.

<script>
  import {
    Collapse,
    Navbar,
    NavbarToggler,
    NavbarBrand,
    Nav,
    NavItem,
    NavLink,
    UncontrolledDropdown,
    DropdownToggle,
    DropdownMenu,
    DropdownItem
  } from 'sveltestrap';

  let isOpen = false;

  function handleUpdate(event) {
    isOpen = event.detail.isOpen;
  }
</script>

<Navbar color="light" light expand="md">
  <NavbarBrand href="/">sveltestrap</NavbarBrand>
  <NavbarToggler on:click={() => (isOpen = !isOpen)} />
  <Collapse {isOpen} navbar expand="md" on:update={handleUpdate}>
    <Nav class="ml-auto" navbar>
      <NavItem>
        <NavLink href="#components/">Components</NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="https://github.com/bestguy/sveltestrap">GitHub</NavLink>
      </NavItem>
      <UncontrolledDropdown nav inNavbar>
        <DropdownToggle nav caret>Options</DropdownToggle>
        <DropdownMenu right>
          <DropdownItem>Option 1</DropdownItem>
          <DropdownItem>Option 2</DropdownItem>
          <DropdownItem divider />
          <DropdownItem>Reset</DropdownItem>
        </DropdownMenu>
      </UncontrolledDropdown>
    </Nav>
  </Collapse>
</Navbar>

VM997:644 Uncaught DOMException: Failed to execute 'postMessage' on 'Window': function fill() { [native code] } could not be cloned.
    at Object.add (<anonymous>:644:14)
    at add (<anonymous>:11:51)
    at addNode (<anonymous>:104:5)
    at Object.block.m (<anonymous>:244:11)
    at mount_component (http://localhost:5000/build/bundle.js:534:30)
    at mount (http://localhost:5000/build/bundle.js:6151:8)
    at updateProfile (<anonymous>:49:7)
    at Object.block.m (<anonymous>:248:9)
    at mount (http://localhost:5000/build/bundle.js:2177:22)
    at updateProfile (<anonymous>:49:7)

Useless "toggle" attribute in Modal code

Using Modal I noticed a strange thing also in the Storybook one:

image

Do you see the toggle="()=>$$invalidate("open",open=!open)" string in div?

I think it comes from <div {...props} in Modal.svelte.

Do we really need it?

Componentize all SCSS

To make the payload as light as possible, it would be beneficial to componentize all SCSS.

The bootstrap *.scss libraries can be encapsulated within a component that uses global styles. The https://www.npmjs.com/package/@ctx-core/sass package has a sass/scss & global css preprocessor.

This could be the bootstrap base component:

<!--src/Bootstrap.svelte-->
<style type=text/scss global>
	@import '~bootstrap/scss/variables';
	// ...
</style>
<!--src/Grid.svelte-->
<script>
	include Bootstrap from './Bootstrap.svelte'
</script>
<Bootstrap></Bootstrap>
<style type=text/scss global>
	@import '~bootstrap/scss/mixins/grid';
	// ...
</style>

This could be a widget (e.g. carousel):

<!--src/Carousel.svelte-->
<script>
	include Grid from './Grid.svelte'
</script>

<Grid></Grid>
<!--Rest of Carousel.svelte template-->

<style type=text/scss global>
	@include "~bootstrap/scss/mixins/carousel"
</style>

conditionallyUpdateScrollbar and forced reflows

I think we have an issue with conditionallyUpdateScrollbar().

image

I'm not an expert here but maybe we can fix this in some way?

Forced reflows on low-(very low)-end devices is a serious problem (many many lags).

Take advantage of slots

We could probably improve many components by adding slot supports for headers, etc vs having to manually nest CardHeader, CardFooter, ToastHeader, alert-heading classes, etc.

Styles Overwritten

I have an issue with styles being overwritten and would like some information on how to fix it.

In a component, I import the Card, and related, components from sveltestrap.

When I add CardTitle to my markup, I see that sveltestrap adds it as a div, rather than the h5 in the bootstrap docs that allows for the proper styling.

To change the styling for all CardTitles in my app, I add a .card-title declaration to global.css. This changes the card title after save. However, if I resave the component file, or a refresh, the styles get lost, and the card title goes back to incorrect styling.

What do I need to do to overwrite these styles, or change the element type?

adding card component breaks sapper nav

  • install sapper template npx degit "sveltejs/sapper-template#rollup myapp
  • install sveltestrap, include css from cdn
  • include card component
import { Card, CardBody } from "sveltestrap";
</script>

The component renders, but when I change tabs, I get the following console error:

sveltestrap.es.js:1 Uncaught (in promise) TypeError: Cannot read property 'c' of undefined
    at os (sveltestrap.es.js:1)
    at Object.o (sveltestrap.es.js:1)
    at transition_out (index.mjs:672)
    at Object.outro [as o] (sveltestrap.es.js:1)
    at transition_out (index.mjs:672)
    at Object.update [as p] (App.svelte:22)
    at Object.update [as p] (App.svelte:19)
    at Object.update [as p] (_layout.svelte:18)
    at update (index.mjs:619)
    at flush (index.mjs:593)

repro at https://codesandbox.io/s/7synm

Label has unused export property

Thank you for this library. When trying the example from the README, I get warnings :

image

Label has unused export property 'xs'. If it is for external reference only, please consider using `export const 'xs'` (Label.svelte:20:13)

Label has unused export property 'sm'. If it is for external reference only, please consider using `export const 'sm'` (Label.svelte:21:13)

Label has unused export property 'md'. If it is for external reference only, please consider using `export const 'md'` (Label.svelte:22:13)

Label has unused export property 'lg'. If it is for external reference only, please consider using `export const 'lg'` (Label.svelte:23:13)

Label has unused export property 'xl'. If it is for external reference only, please consider using `export const 'xl'` (Label.svelte:24:13)

Label has unused export property 'widths'. If it is for external reference only, please consider using `export const 'widths'` (Label.svelte:25:13)

Uglifyjs fails when bundling components

I'm using Svelte and this package to build a simple web app. When I try to use uglifyjs on components I get an error...

(uglify plugin) Error transforming bundle with 'uglify' plugin: Unexpected token punc «(», expected punc «:»

If I remove the import statement for sveltestrap all is fine.

rollup.config.js

import * as fs from 'fs';
import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import buble from 'rollup-plugin-buble';
import uglify from 'rollup-plugin-uglify';
import CleanCSS from 'clean-css';

const production = !!process.env.production;

export default {
	entry: 'src/main.js',
	dest: 'js/bundle.js',
	format: 'iife',
	moduleName: 'app',
	sourceMap: true,
	plugins: [
		svelte({
			// we'll extract any component CSS out into
			// a separate file — better for performance
			css( css ) {
				if ( css === null ) css = '';
				if ( production ) css = new CleanCSS().minify( css ).styles;
				fs.writeFileSync(
					'app.css',
					`/* This file is automatically generated — don't edit it! */\n${css}`
				);
			}
		}),
		// If you have external dependencies installed from
		// npm, you'll most likely need these plugins. In
		// some cases you'll need additional configuration —
		// consult the documentation for details:
		// https://github.com/rollup/rollup-plugin-commonjs
		resolve(),
		commonjs(),

		// If we're building for production (npm run build
		// instead of npm run dev), transpile and minify
		production && buble({ exclude: 'node_modules/**' }),
		production && uglify()
	]
};

main.js

import './jquery-global.js';
import 'bootstrap';
import 'bootstrap-select';

import App 						from './App.html';

var app = new App({
    target: document.body,
    data: {
    }
});

export default app;

App.html

<Container>
    <Row>
        <Col>
            {{#each buttons as button}}
                <Button on:click='onButtonClick(button)' color='{{button.color}}'>{{button.name}}</Button>&nbsp;&nbsp;
            {{/each}}
        </Col>
    </Row>
    <Row>&nbsp;&nbsp;</Row>
    <Row>&nbsp;&nbsp;</Row>
    <Row>
        {{#if show}}
        <Alert dismissible color="{{color}}">
            <h4>Alert popup - {{name}}</h4>
        </Alert>
        {{/if}}
    </Row>
</Container>

<script>
    import { Container, Button, Col, Row, Alert } from 'sveltestrap';

    export default {
        components: { Container, Alert, Button, Col, Row },
        data () {
            return {
                buttons: [
                    { 'color': 'primary', 'name': 'Primary', alert: false },
                    { 'color': 'default', 'name': 'Secondary', alert: false },
                    { 'color': 'success', 'name': 'Success', alert: true },
                    { 'color': 'info', 'name': 'Info', alert: true },
                    { 'color': 'warning', 'name': 'Warning', alert: true },
                    { 'color': 'danger', 'name': 'Danger', alert: true },
                    { 'color': 'link', 'name': 'Link', alert: false }
                ],
                name: '',
                color: '',
                show: false
            }
        },
        methods: {
            onButtonClick(e){
                if (e.alert) {
                    this.set({'show': true, 'color': e.color, 'name': e.name});
                } else {
                    this.set({'show': false});
                }
            }
        }
    }
</script>

Problem Modal Cannot read property 'c' of undefined

this error happens when you want to close the modal

Error:
index.mjs:676 Uncaught (in promise) TypeError: Cannot read property 'c' of undefined

    "npm-run-all": "^4.1.5",
    "rollup": "^1.12.0",
    "rollup-plugin-commonjs": "^10.0.0",
    "rollup-plugin-livereload": "^1.0.0",
    "rollup-plugin-node-resolve": "^5.2.0",
    "rollup-plugin-svelte": "^5.0.3",
    "rollup-plugin-terser": "^4.0.4",
    "svelte": "^3.12.1"
  },
  "dependencies": {
    "sirv-cli": "^0.4.4",
    "sveltestrap": "^3.1.1"
  }

"window is not defined" in SSR/Sapper when using NavbarToggler/Collapse

I've read through a few issues already and there were multiple mentions of importing the source directly for components when using Sapper and that fixing people's issues when combining SSR and NavbarToggler/Collapse. Unfortunately, that did not solve it for me.

It did allow me to render the Navbar, however, when adding NavbarToggler/Collapse to the picture, my app seems to need the window context. Could it be that this is on purpose? Could it be servers-side rendered or is this an unfortunate bug in the framework?

My code is the simple template from the sveltestrap demo for Navigation.

<script>
  import Collapse from "sveltestrap/src/Collapse.svelte";
  import Navbar from "sveltestrap/src/Navbar.svelte";
  import NavbarToggler from "sveltestrap/src/NavbarToggler.svelte";
  import NavbarBrand from "sveltestrap/src/NavbarBrand.svelte";
  import Nav from "sveltestrap/src/Nav.svelte";
  import NavItem from "sveltestrap/src/NavItem.svelte";
  import NavLink from "sveltestrap/src/NavLink.svelte";

  let isOpen = false;

  function handleUpdate(event) {
    isOpen = event.detail.isOpen;
  }
</script>

<Navbar color="light" light expand="md">
  <NavbarBrand href="/">sveltestrap</NavbarBrand>
  <NavbarToggler on:click={() => (isOpen = !isOpen)} />
  <Collapse {isOpen} navbar expand="md" on:update={handleUpdate}>
  <Nav class="ml-auto" navbar pills>
    <NavItem>
      <NavLink href="." active>Components</NavLink>
    </NavItem>
    <NavItem>
      <NavLink href="/">GitHub</NavLink>
    </NavItem>
  </Nav>
  </Collapse>
</Navbar>

Styling

How does one style the sveltestrap components?
I am attempting to style the drop down and yeah. No idea how to do it.

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.