mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
[ci] yarn format
This commit is contained in:
parent
81c01d121f
commit
02ecaf3d33
5 changed files with 34 additions and 41 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { h, Fragment } from 'preact';
|
import { h, Fragment } from 'preact';
|
||||||
import { useStore } from 'nanostores/preact'
|
import { useStore } from 'nanostores/preact';
|
||||||
|
|
||||||
import { admins } from '../store/admins.js'
|
import { admins } from '../store/admins.js';
|
||||||
import { counter, increaseCounter, decreaseCounter } from '../store/counter.js';
|
import { counter, increaseCounter, decreaseCounter } from '../store/counter.js';
|
||||||
|
|
||||||
const AdminsPreact = () => {
|
const AdminsPreact = () => {
|
||||||
|
@ -12,7 +12,9 @@ const AdminsPreact = () => {
|
||||||
<>
|
<>
|
||||||
<h1>Preact</h1>
|
<h1>Preact</h1>
|
||||||
<ul>
|
<ul>
|
||||||
{list.map(user => <li key={user.name}>{JSON.stringify(user, null, 2)}</li>)}
|
{list.map((user) => (
|
||||||
|
<li key={user.name}>{JSON.stringify(user, null, 2)}</li>
|
||||||
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
<div>
|
<div>
|
||||||
<h3>Counter</h3>
|
<h3>Counter</h3>
|
||||||
|
@ -22,6 +24,6 @@ const AdminsPreact = () => {
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default AdminsPreact
|
export default AdminsPreact;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react'
|
import React from 'react';
|
||||||
import { useStore } from 'nanostores/react'
|
import { useStore } from 'nanostores/react';
|
||||||
|
|
||||||
import { admins } from '../store/admins.js'
|
import { admins } from '../store/admins.js';
|
||||||
import { counter, increaseCounter, decreaseCounter } from '../store/counter.js';
|
import { counter, increaseCounter, decreaseCounter } from '../store/counter.js';
|
||||||
|
|
||||||
const AdminsReact = () => {
|
const AdminsReact = () => {
|
||||||
|
@ -11,7 +11,9 @@ const AdminsReact = () => {
|
||||||
<>
|
<>
|
||||||
<h1>React</h1>
|
<h1>React</h1>
|
||||||
<ul>
|
<ul>
|
||||||
{list.map(user => <li key={user.name}>{JSON.stringify(user, null, 2)}</li>)}
|
{list.map((user) => (
|
||||||
|
<li key={user.name}>{JSON.stringify(user, null, 2)}</li>
|
||||||
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
<div>
|
<div>
|
||||||
<h3>Counter</h3>
|
<h3>Counter</h3>
|
||||||
|
@ -22,6 +24,6 @@ const AdminsReact = () => {
|
||||||
<br />
|
<br />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default AdminsReact;
|
export default AdminsReact;
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import { createDerived } from 'nanostores'
|
import { createDerived } from 'nanostores';
|
||||||
|
|
||||||
import { users } from './users.js'
|
import { users } from './users.js';
|
||||||
|
|
||||||
const admins = createDerived(users, list =>
|
const admins = createDerived(users, (list) => list.filter((user) => user.isAdmin));
|
||||||
list.filter(user => user.isAdmin)
|
|
||||||
)
|
|
||||||
|
|
||||||
export {
|
export { admins };
|
||||||
admins
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
import { createStore, getValue } from 'nanostores'
|
import { createStore, getValue } from 'nanostores';
|
||||||
|
|
||||||
const counter = createStore(() => {
|
const counter = createStore(() => {
|
||||||
counter.set(0)
|
counter.set(0);
|
||||||
})
|
});
|
||||||
|
|
||||||
function increaseCounter() {
|
function increaseCounter() {
|
||||||
counter.set(getValue(counter) + 1)
|
counter.set(getValue(counter) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function decreaseCounter() {
|
function decreaseCounter() {
|
||||||
counter.set(getValue(counter) - 1)
|
counter.set(getValue(counter) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export { counter, increaseCounter, decreaseCounter };
|
||||||
counter,
|
|
||||||
increaseCounter,
|
|
||||||
decreaseCounter
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,30 +1,27 @@
|
||||||
import { createStore, getValue } from 'nanostores'
|
import { createStore, getValue } from 'nanostores';
|
||||||
|
|
||||||
const users = createStore(() => {
|
const users = createStore(() => {
|
||||||
users.set([
|
users.set([
|
||||||
{
|
{
|
||||||
name: 'Imanadmin',
|
name: 'Imanadmin',
|
||||||
age: 2,
|
age: 2,
|
||||||
isAdmin: true
|
isAdmin: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Imnotadmin',
|
name: 'Imnotadmin',
|
||||||
age: 35,
|
age: 35,
|
||||||
isAdmin: false
|
isAdmin: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Wowsomuchadmin',
|
name: 'Wowsomuchadmin',
|
||||||
age: 3634,
|
age: 3634,
|
||||||
isAdmin: true
|
isAdmin: true,
|
||||||
},
|
},
|
||||||
])
|
]);
|
||||||
})
|
});
|
||||||
|
|
||||||
const addUser = function addUser(user) {
|
const addUser = function addUser(user) {
|
||||||
users.set([...getValue(users), user])
|
users.set([...getValue(users), user]);
|
||||||
}
|
};
|
||||||
|
|
||||||
export {
|
export { users, addUser };
|
||||||
users,
|
|
||||||
addUser
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue