Skip to content

Commit

Permalink
Fix/button (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaxus authored Sep 22, 2023
1 parent 1045ccf commit 811e2a4
Show file tree
Hide file tree
Showing 57 changed files with 1,839 additions and 288 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = defineConfig({
ecmaVersion: 2021,
},
rules: {
eqeqeq: ['warn', 'always', { null: 'never' }],
// eqeqeq: ['warn', 'always', { null: 'never' }],
'no-debugger': ['error'],
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-process-exit': 'off',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI
on:
pull_request:
branches: main
push:
push:
branches: main
jobs:
lint:
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"IIFE",
"keyof",
"Metiral",
"nums",
"Ovride",
"picocolors",
"preinstall",
Expand Down
2 changes: 1 addition & 1 deletion bin/build.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npx pnpm -F ranuts build && pnpm -F ranui build && pnpm -F docs build
npx pnpm -F ranuts build && pnpm -F ranui build && pnpm -F ranui-react build && pnpm -F docs build
3 changes: 2 additions & 1 deletion bin/test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pnpm -F ranuts test
pnpm -F ranuts build
pnpm -F ranui test
pnpm -F ranui test
pnpm -F ranui-react test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"eslint-plugin-regexp": "^1.11.0",
"prettier": "^2.8.1",
"terser": "^5.15.0",
"typescript": "^4.8.3"
"typescript": "^5.2.2"
}
}
Binary file modified packages/.DS_Store
Binary file not shown.
54 changes: 54 additions & 0 deletions packages/docs/.vitepress/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
export const GTAG = 'https://www.googletagmanager.com/gtag/js?id=G-0MPS5WH1C0'

export const GOOGLE_ANALYSE = `;window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);};gtag('js', new Date());gtag('config', 'G-0MPS5WH1C0');`

export const BD_ANALYSE = `
;var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?3bc20bd8070ce614078a36c686209456";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
`

export const PREVIEW_CODE = `
window.uploadFile = (name) => {
const preview = document.getElementById(name)
const uploadFile = document.createElement('input')
uploadFile.setAttribute('type', 'file')
uploadFile.click()
uploadFile.onchange = (e) => {
const { files = [] } = uploadFile
if (preview) {
if (files && files.length > 0) {
preview.setAttribute('src', '')
const file = files[0]
const url = URL.createObjectURL(file)
preview.setAttribute('src', url)
}
}
}
}
`

export const DESCRIPTION =
'Based on web component library, common function library utils, personal article record and so on'

export const HOME = 'https://chaxus.github.io/ran/'

export const BASE_PATH = '/ran/'

export const HOME_ICON = `${HOME}home.svg`

export const UTILS_PATH = `${HOME}src/ranuts/utils/`

export const RANUI_PATH = `${HOME}src/ranui/`

export const ARTICLE_PATH = `${HOME}src/article/designMode.html`

export const KEY_WORDS =
'ran,component,components,ui,design,ranui,web-components,javascript,typescript,js'

export const GITHUB = 'https://github.com/chaxus/ran'

94 changes: 50 additions & 44 deletions packages/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,23 @@
import { defineConfig } from 'vitepress'
import {
GTAG,
GOOGLE_ANALYSE,
BD_ANALYSE,
PREVIEW_CODE,
DESCRIPTION,
HOME,
HOME_ICON,
UTILS_PATH,
RANUI_PATH,
ARTICLE_PATH,
KEY_WORDS,
GITHUB,
BASE_PATH
} from './common/index'

const BASE_PATH = '/ran/'

const GTAG = 'https://www.googletagmanager.com/gtag/js?id=G-0MPS5WH1C0'

const googleAnalyse = `;window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);};gtag('js', new Date());gtag('config', 'G-0MPS5WH1C0');`

const baiduAnalyse = `
;var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?3bc20bd8070ce614078a36c686209456";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
`

const previewCode = `
window.uploadFile = (name) => {
const preview = document.getElementById(name)
const uploadFile = document.createElement('input')
uploadFile.setAttribute('type', 'file')
uploadFile.click()
uploadFile.onchange = (e) => {
const { files = [] } = uploadFile
if (preview) {
if (files && files.length > 0) {
preview.setAttribute('src', '')
const file = files[0]
const url = URL.createObjectURL(file)
preview.setAttribute('src', url)
}
}
}
}
`
export default defineConfig({
title: 'ran',
description: '基于web component组件库,常用函数库utils,个人文章记录等',
description: DESCRIPTION,
base: BASE_PATH,
lastUpdated: true,
locales: {
Expand All @@ -53,17 +33,43 @@ export default defineConfig({
},
},
head: [
// base
['link', { rel: 'icon', href: `${BASE_PATH}favicon.ico` }],
['meta', { property: 'og:type', content: 'website' }],
['meta', { name: 'theme-color', content: '#646cff' }],
// og
['meta', { property: 'og:title', content: 'ran' }],
[
'meta',
{
property: 'og:description',
content: DESCRIPTION,
},
],
['meta', { property: 'og:url', content: HOME }],
['meta', { property: 'og:image', content: HOME_ICON }],
['meta', { property: 'og:type', content: 'article' }],
[
'meta',
{
property: 'article:home',
content: UTILS_PATH,
},
],
['meta', { property: 'article:ranui', content: RANUI_PATH }],
['meta', { property: 'article:section', content: ARTICLE_PATH }],
// keywords
['meta', { name: 'keywords', content: KEY_WORDS }],
// chrome
[
'meta',
{ httpEquiv: 'Permissions-Policy', content: 'interest-cohort=()' },
],
// report
['script', { src: GTAG }],
['script', {}, googleAnalyse],
['script', {}, baiduAnalyse],
['script', {}, previewCode],
['script', { defer: "true" }, GOOGLE_ANALYSE],
['script', { defer: "true" }, BD_ANALYSE],
// preview component script
['script', {}, PREVIEW_CODE],
],
themeConfig: {
logo: '/home.svg',
Expand All @@ -73,15 +79,15 @@ export default defineConfig({
{ text: '组件', link: '/src/ranui/' },
{ text: '璀璨', link: '/src/article/designMode.md' },
],
socialLinks: [{ icon: 'github', link: 'https://github.com/chaxus/ran' }],
socialLinks: [{ icon: 'github', link: GITHUB }],
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2022-11-11',
},
// algolia: {
// appId: 'RDX0Y4AQW1',
// apiKey: 'c7b6e28f95335eddc66c5a1b54ad9834',
// indexName: 'chaxus_ran',
// appId: 'RDX0Y4AQW1',
// apiKey: 'c7b6e28f95335eddc66c5a1b54ad9834',
// indexName: 'chaxus_ran',
// placeholder: 'search',
// },
sidebar: {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/article/astParse/tokenizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ type SingleCharTokens = '(' | ')' | '{' | '}' | '='
// 单字符到 Token 生成器的映射
const KNOWN_SINGLE_CHAR_TOKENS = new Map<
SingleCharTokens,
typeof TOKENS_GENERATOR[keyof typeof TOKENS_GENERATOR]
(typeof TOKENS_GENERATOR)[keyof typeof TOKENS_GENERATOR]
>([
['(', TOKENS_GENERATOR.leftParen],
[')', TOKENS_GENERATOR.rightParen],
Expand Down
8 changes: 4 additions & 4 deletions packages/docs/src/ranui/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ import 'ranui'
<r-button id="button">按钮</r-button>

<script>
const button = document.getElementById('button');
button.addEventListener('click', function(event) {
alert('新的点击事件!');
});
const button = document.getElementById('button')
button.addEventListener('click', function (event) {
alert('新的点击事件!')
})
</script>
```

Expand Down
Loading

0 comments on commit 811e2a4

Please sign in to comment.