@undp-data/svelte-copy-to-clipboard
This is a svelte package of copy to clipboard component.
Requirements
This package uses bulma css and fontawesome icon. You need to import their CSSs to use this package. For example,
<svelte:head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"
integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
</svelte:head>
Usage
<script lang="ts">
import { CopyToClipboard } from '@undp-data/svelte-copy-to-clipboard';
let value = 'text to copy to clipboard';
</script>
<CopyToClipboard
bind:value
placeholder="Copy to clipboard"
textCopy="Copy"
textCopied="Copied"
width="100%"
timeout={5000}
isMultiline={false}
/>
create-svelte
Everything you need to build a Svelte library, powered by create-svelte
.
Read more about creating a library in the docs.
Creating a project
If you're seeing this, you've probably already done this step. Congrats!
npm create svelte@latest
npm create svelte@latest my-app
Developing
Once you've created a project and installed dependencies with npm install
(or pnpm install
or yarn
), start a development server:
npm run dev
npm run dev -- --open
Everything inside src/lib
is part of your library, everything inside src/routes
can be used as a showcase or preview app.
Building
To build your library:
npm run package
To create a production version of your showcase app:
npm run build
You can preview the production build with npm run preview
.
To deploy your app, you may need to install an adapter for your target environment.
Publishing
Go into the package.json
and give your package the desired name through the "name"
option. Also consider adding a "license"
field and point it to a LICENSE
file which you can create from a template (one popular option is the MIT license).
To publish your library to npm:
npm publish