Skip to content

Commit fa5176b

Browse files
committed
feat: Add interactive playground with GitHub Pages deployment
Introduces a browser-based playground for experimenting with CSS selector parsing, featuring real-time syntax highlighting, AST visualization, and configurable parser options. Includes automated deployment workflow for GitHub Pages.
1 parent f04297f commit fa5176b

File tree

11 files changed

+2168
-1
lines changed

11 files changed

+2168
-1
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Deploy Playground to GitHub Pages
2+
3+
on:
4+
release:
5+
types: [published, created]
6+
# Allow manual trigger for testing
7+
workflow_dispatch:
8+
9+
# Sets permissions for GitHub Pages deployment
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
# Allow only one concurrent deployment
16+
concurrency:
17+
group: "pages"
18+
cancel-in-progress: false
19+
20+
jobs:
21+
build-and-deploy:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '18.x'
34+
cache: 'npm'
35+
36+
- name: Install dependencies
37+
run: npm ci --prefer-offline --no-audit --no-update-notifier
38+
39+
- name: Run linting
40+
run: npm run lint
41+
42+
- name: Run tests
43+
run: npm run test
44+
45+
- name: Build library
46+
run: npm run build
47+
48+
- name: Build documentation
49+
run: npm run build:docs
50+
51+
- name: Update playground version
52+
run: |
53+
VERSION=$(node -p "require('./package.json').version")
54+
echo "Updating playground to version $VERSION"
55+
find playground -type f \( -name '*.js' -o -name '*.html' \) -exec sed -i.bak "s/css-selector-parser@[0-9.]*[0-9]/css-selector-parser@$VERSION/g" {} \;
56+
find playground -type f -name '*.bak' -delete
57+
58+
- name: Prepare deployment directory
59+
run: |
60+
mkdir -p deploy
61+
# Copy playground files
62+
cp -r playground/* deploy/
63+
# Copy documentation
64+
cp -r docs deploy/docs
65+
# Ensure .nojekyll exists to prevent Jekyll processing
66+
touch deploy/.nojekyll
67+
echo "Deployment directory contents:"
68+
ls -la deploy/
69+
70+
- name: Setup GitHub Pages
71+
uses: actions/configure-pages@v4
72+
73+
- name: Upload artifact
74+
uses: actions/upload-pages-artifact@v3
75+
with:
76+
path: 'deploy'
77+
78+
- name: Deploy to GitHub Pages
79+
id: deployment
80+
uses: actions/deploy-pages@v4
81+
82+
- name: Output deployment URL
83+
run: |
84+
echo "โœ… Playground deployed successfully!"
85+
echo "๐ŸŽฎ Playground URL: https://mdevils.github.io/css-selector-parser/"
86+
echo "๐Ÿ“š Documentation: https://mdevils.github.io/css-selector-parser/docs/"

โ€ŽREADME.mdโ€Ž

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,26 @@ A high-performance CSS selector parser with advanced features for modern web dev
1212
- ๐Ÿš€ **Fast and memory-efficient** parsing for all CSS selectors
1313
- ๐ŸŒณ **AST-based** object model for programmatic manipulation
1414
- ๐Ÿ“Š **Full compliance** with all CSS selector specifications
15-
- ๐Ÿงช **Comprehensive test coverage**
15+
- ๐Ÿงช **Comprehensive test coverage**
1616
- ๐Ÿ“š **Well-documented API** with TypeScript support
1717
- ๐Ÿ”„ **Two-way conversion** between CSS selectors and AST
1818
- ๐Ÿงฉ **Modular support** for various CSS specifications
19+
- ๐ŸŽฎ **[Interactive Playground](https://mdevils.github.io/css-selector-parser/)** - Try it in your browser!
20+
21+
## Playground
22+
23+
Try the interactive playground to explore the parser's capabilities:
24+
25+
**[๐ŸŽฎ Launch Playground](https://mdevils.github.io/css-selector-parser/)**
26+
27+
The playground allows you to:
28+
- โœ๏ธ Write CSS selectors with syntax highlighting
29+
- โš™๏ธ Configure parser options in real-time
30+
- ๐ŸŒณ View the parsed AST structure
31+
- ๐Ÿงช Test different CSS syntax levels and modules
32+
- โœ… See rendered output for validation
33+
34+
Perfect for learning, debugging, and exploring CSS selector syntax!
1935

2036
## Supported CSS Selector Standards
2137

โ€Žplayground/.eslintrcโ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"browser": true
4+
}
5+
}

0 commit comments

Comments
ย (0)