Skip to content

Commit

Permalink
export ChessgroundUnstyled component
Browse files Browse the repository at this point in the history
  • Loading branch information
gtim committed Jun 21, 2023
1 parent 934a10c commit 8caaec8
Show file tree
Hide file tree
Showing 5 changed files with 385 additions and 4 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ Chessground can be completely restyled through CSS. The component imports defaul
}
</style>

2. Apply your own full chessground stylesheet instead of the defaults by setting the `className` prop and importing your own stylesheet. By changing the class name from the default, none of the default stylesheets will apply, not even the piece SVGs.
2. Apply your own full chessground stylesheet instead of the defaults by setting the `className` prop and importing your own stylesheet.
By changing the class name from the default, none of the default stylesheets will apply, not even the piece SVGs.
Additionally, you can use the provided `ChessgroundUnstyled` component, which is completely unstyled.

<script>
import {ChessgroundUnstyled} from 'svelte-chessground';
import '$lib/my-chessboard.css';
</script>
<Chessground className="my-chessboard" />
<ChessgroundUnstyled className="my-chessboard" />

You can find working code for both approaches in the [custom styles examples](https://github.com/gtim/svelte-chessground-examples/blob/main/src/routes/style/%2Bpage.svelte).

Expand Down
15 changes: 15 additions & 0 deletions generate_unstyled.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generate ChessgroundUnstyled.svelte from Chessground.svelte

use 5.30.0;
use warnings;
use File::Slurper qw/read_text write_text/;

my $unstyled = read_text( 'src/lib/Chessground.svelte' );

# remove entire <style> except for a .cg-wrap{...} at the beginning
$unstyled =~ s@<style>(\s*\.cg-wrap\s+\{.*?\}).*</style>@<style>$1\n</style>@s;

# add file-is-generated comment
$unstyled =~ s@(<script>)@$1\n\t// This file was generated by generate_unstyled.pl\n\t@;

write_text( 'src/lib/ChessgroundUnstyled.svelte', $unstyled );
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"chessground",
"chessboard"
],
"version": "1.0.0",
"version": "1.1.0",
"license": "GPL-3.0",
"homepage": "https://github.com/gtim/svelte-chessground#readme",
"bugs": "https://github.com/gtim/svelte-chessground/issues",
"scripts": {
"dev": "vite dev",
"build": "vite build && npm run package",
"build": "perl generate_unstyled.pl && vite build && npm run package",
"preview": "vite preview",
"package": "svelte-kit sync && svelte-package && publint",
"prepublishOnly": "npm run package",
Expand Down
Loading

0 comments on commit 8caaec8

Please sign in to comment.