Svelma is a set of UI components for Svelte based on the Bulma CSS framework.
Much thanks to the Buefy project! It provided the inspiration and lots of code examples for Svelma.. If you like Vue.js and Bulma, check it out.
- Extremely lightweight thanks to Svelte, a compile-only javascript framework. The bundle is
50K
minified,14K
gzipped. - Components can be used independently, so a modern tree-shaking bundler will reduce the final bundle size even further.
- Svelma does not bundle Bulma, so you are free to include it in your project however you wish, themes and all.
https://github.com/sveltejs/template is a template repo for svelte. degit will scaffold the repo for you:
$ npx degit sveltejs/template my-svelma-project
$ cd my-svelma-project
$ npm install
NOTE: There are of course other ways to set up a project using svelte. This is just the quickest way to start.
Note that you'll need a CSS processing plugin for rollup so that you can import css files. Here we're using rollup-plugin-postcss
. If you're going to use a
<link>
tag in your HTML you can skip the plugin and the import ... css
statement below in step #2
$ npm install --save bulma svelma
$ npm install node-sass svelte-preprocess rollup-plugin-postcss --save-dev
Add the postcss plugin to your rollup config (I don't think the order really matters):
// rollup.config.js
import postcss from 'rollup-plugin-postcss'
import preprocess from 'svelte-preprocess'
// ...
export default {
// ...
plugins: [
svelte({
// ...
preprocess: preprocess()
}),
postcss(),
}
}
<!-- App.svelte -->
<script>
import 'bulma/css/bulma.css'
import { Button } from 'svelma'
</script>
<button type="is-primary">I'm a Button!</button>
4. Include Font Awesome icons
From CDN in your HTML page:
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"></link>
...or as an npm package imported into your root component:
$ npm install --save @fortawesome/fontawesome-free
<!-- App.svelte -->
<script>
import 'bulma/css/bulma.css'
import '@fortawesome/fontawesome-free/css/all.css'
</script>
If you are doing server-side rendering with Sapper, you'll need to import the .svelte files directly so that your app can compile them, rather than importing from the compiled module.
i.e.:
import Button from 'svelma/src/components/Button.svelte'
instead of
import { Button } from 'svelma'
- Clone this repo:
git clone https://github.com/c0bra/svelma.git
- Install dependencies:
npm i && (cd docs; npm i)
npm install -g semantic-release-cli commitizen
- Start the automated build and automated docs:
npm run dev
- Open url that console prints in your browser
$ git cz
NOTE: CI should publish new versions using semantic-release
automatically
$ npm version <version>
$ npm publish
Code released under MIT license.
Copyright ©, Brian Hann.