Skip to content

Commit

Permalink
feat: init project
Browse files Browse the repository at this point in the history
  • Loading branch information
NWYLZW committed Aug 5, 2023
0 parents commit 95cccff
Show file tree
Hide file tree
Showing 34 changed files with 2,205 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
insert_final_newline = true
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
100 changes: 100 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended'
],
overrides: [
{
plugins: ['react', '@typescript-eslint'],
files: ['*.ts', '*.tsx'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unused-vars': [
'error', {
varsIgnorePattern: '^_',
argsIgnorePattern: '^_'
}
],
'react/react-in-jsx-scope': 'off',
// TODO fix start
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/dist', '**/dist/**'],
message: 'Don not import from dist',
allowTypeImports: false
},
{
group: ['**/src', '**/src/**'],
message: 'Don not import from src',
allowTypeImports: false
}
]
}
],
// end
}
},
],
settings: {
react: {
version: '18'
}
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: ['react', '@typescript-eslint', 'simple-import-sort'],
rules: {
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', disallowTypeAnnotations: false }
],
'@typescript-eslint/no-namespace': 'off',
'no-unused-vars': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'semi': ['error', 'never'],
'keyword-spacing': ['error', { before: true, after: true }],
'space-before-blocks': ['error', 'always'],
'comma-dangle': ['error', 'never'],
'comma-spacing': ['error', { before: false, after: true }],
'no-multi-spaces': ['error', {
ignoreEOLComments: true
}],
'block-spacing': 'error',
'array-bracket-spacing': ['error', 'never'],
'object-curly-spacing': ['error', 'always'],
'indent': ['error', 2, {
SwitchCase: 1,
VariableDeclarator: 'first',
// ignore jsx node, template literal expression
ignoredNodes: ['JSXElement *', 'TemplateLiteral *']
}],
'jsx-quotes': ['error', 'prefer-single'],
'react/prop-types': 'off',
'react/jsx-indent': ['error', 2],
'react/jsx-indent-props': ['error', 'first'],
'react/jsx-tag-spacing': ['error', {
closingSlash: 'never',
beforeSelfClosing: 'always',
afterOpening: 'never',
beforeClosing: 'never',
}],
}
}
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Envrioment
.env

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.vercel
7 changes: 7 additions & 0 deletions core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@power-playground/core",
"version": "1.0.0",
"dependencies": {
"react": "^18.2.0"
}
}
28 changes: 28 additions & 0 deletions core/public/front_end/chii_app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>DevTools</title>
<style>
@media (prefers-color-scheme: dark) {
body {
background-color: rgb(41 42 45);
}
}
</style>
<meta name="referrer" content="no-referrer">
<script src="//cdn.jsdelivr.net/npm/sentinel-js"></script>
<script type="module">
sentinel.on('.main-tabbed-pane', el => {
const style = document.createElement('style')
style.innerText = `
.tabbed-pane-header > .tabbed-pane-left-toolbar.toolbar {
display: none !important;
}`
el.shadowRoot.prepend(style)
})
</script>
<script type="module">
window.simport = path => import(`https://cdn.jsdelivr.net/npm/chii/public/front_end/${path}`)
</script>
<script type="module" src="//cdn.jsdelivr.net/npm/chii/public/front_end/entrypoints/chii_app/chii_app.js"></script>
<body class="undocked" id="-blink-dev-tools">
2 changes: 2 additions & 0 deletions core/public/target.js

Large diffs are not rendered by default.

205 changes: 205 additions & 0 deletions core/src/components/EditorZone.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
dialog {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 0;
width: 100vw;
height: 100vh;
background-color: #0005;
outline: none;
border: none;
> .dialog__container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 50vw;
max-height: 80vh;
padding: 20px 30px;
color: var(--fr-cr);
background-color: var(--bg-cr);
border-radius: 4px;
overflow: overlay;
transition: .1s;
> .dialog__title {
display: flex;
align-items: center;
justify-content: space-between;
> .dialog__close {
padding: 0;
width: 30px;
height: 30px;
background-color: #0000;
color: var(--fr-cr);
border: none;
outline: none;
cursor: pointer;
font-size: 1.5em;
font-weight: bold;
transition: .3s;
&:hover { background-color: #0002; }
}
}
}
&.help {
.dialog__content {
font-size: 16px;
h2 { margin-top: 0 }
code {
padding: 2px 4px;

font-size: 14px;
background-color: #0002;
border-radius: 4px;
html[theme-mode=dark] & {
background-color: #0008;
}
}
}
}
&.history {
> .dialog__container {
display: flex;
flex-direction: column;
height: 80vh;
> .dialog__title {
margin-top: -20px;
margin-left: -30px;
margin-right: -30px;
padding: 5px 15px;
border-bottom: 1px solid var(--primary);
h5 { margin: 0 }
}
}
.dialog__content {
flex-grow: 1;
height: 0;

display: flex;
flex-direction: column;
> .history__list {
display: flex;
flex-direction: column;

height: 30vh;
margin: 0 -30px 0;
overflow: overlay;
> .history__item {
justify-content: space-between;
padding: 5px 0;
border-bottom: 1px solid #0002;
cursor: pointer;
transition: .1s;
&:hover {
background-color: color-mix(in srgb, var(--primary) 50%, transparent);
}
&--selected {
background-color: color-mix(in srgb, var(--primary) 30%, transparent);
}
&:last-child {
border-bottom: none;
margin-bottom: 0;
}
> .history__item__code {
margin: 0;
padding: 0 10px;
font-size: 12px;
text-overflow: ellipsis;
overflow: hidden;
// limit 4 line
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
}
> .history__item__time {
margin: 0;
padding-right: 20px;
font-size: 12px;
color: color-mix(in srgb, var(--fr-cr) 40%, transparent);
text-align: right;
}
}
}
> .preview {
flex-grow: 1;
margin: 0 -30px -20px;
}
}
}
}

div.editor-zone {
position: relative;
max-width: 70vw;
> div.menu {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;

width: 100%;
height: 53px;
padding-right: 10px;

background-color: color-mix(in srgb, var(--primary) 50%, #fff);

color: #fff;
transition: .1s;
> .btns {
display: flex;
flex-direction: row;
align-items: center;
height: 100%;
> button {
padding: 0 20px;
height: 100%;
background-color: #0000;
color: #fff;
border: none;
outline: none;
cursor: pointer;
font-size: 1.5em;
font-weight: bold;
transition: .3s;
&:hover { background-color: #0002; }
}
}
> .opts {
display: flex;
flex-direction: row;
align-items: center;
gap: 5px;
> select {
height: 100%;
padding: 3px 10px;
background-color: #0000;
color: #fff;
border: none;
outline: none;
cursor: pointer;
font-size: 1.2em;
font-weight: bold;
transition: .3s;
&:hover { background-color: var(--primary); }
}
}
}
> section > div {
width: 720px !important;
min-width: 720px !important;
max-width: 100%;
height: calc(100% - 53px) !important;
&::after {
content: '';
position: absolute;
top: -53px;
right: 0;
width: 4px;
height: 100%;
background-color: var(--primary);
cursor: ew-resize;
transition: .3s;
}
}
}
Loading

0 comments on commit 95cccff

Please sign in to comment.