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 { 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';
|
||||
|
||||
const AdminsPreact = () => {
|
||||
|
@ -12,7 +12,9 @@ const AdminsPreact = () => {
|
|||
<>
|
||||
<h1>Preact</h1>
|
||||
<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>
|
||||
<div>
|
||||
<h3>Counter</h3>
|
||||
|
@ -22,6 +24,6 @@ const AdminsPreact = () => {
|
|||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default AdminsPreact
|
||||
export default AdminsPreact;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React from 'react'
|
||||
import { useStore } from 'nanostores/react'
|
||||
import React from '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';
|
||||
|
||||
const AdminsReact = () => {
|
||||
|
@ -11,7 +11,9 @@ const AdminsReact = () => {
|
|||
<>
|
||||
<h1>React</h1>
|
||||
<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>
|
||||
<div>
|
||||
<h3>Counter</h3>
|
||||
|
@ -22,6 +24,6 @@ const AdminsReact = () => {
|
|||
<br />
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
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 =>
|
||||
list.filter(user => user.isAdmin)
|
||||
)
|
||||
const admins = createDerived(users, (list) => list.filter((user) => user.isAdmin));
|
||||
|
||||
export {
|
||||
admins
|
||||
}
|
||||
export { admins };
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
import { createStore, getValue } from 'nanostores'
|
||||
import { createStore, getValue } from 'nanostores';
|
||||
|
||||
const counter = createStore(() => {
|
||||
counter.set(0)
|
||||
})
|
||||
counter.set(0);
|
||||
});
|
||||
|
||||
function increaseCounter() {
|
||||
counter.set(getValue(counter) + 1)
|
||||
counter.set(getValue(counter) + 1);
|
||||
}
|
||||
|
||||
function decreaseCounter() {
|
||||
counter.set(getValue(counter) - 1)
|
||||
counter.set(getValue(counter) - 1);
|
||||
}
|
||||
|
||||
export {
|
||||
counter,
|
||||
increaseCounter,
|
||||
decreaseCounter
|
||||
}
|
||||
export { counter, increaseCounter, decreaseCounter };
|
||||
|
|
|
@ -1,30 +1,27 @@
|
|||
import { createStore, getValue } from 'nanostores'
|
||||
import { createStore, getValue } from 'nanostores';
|
||||
|
||||
const users = createStore(() => {
|
||||
users.set([
|
||||
{
|
||||
name: 'Imanadmin',
|
||||
age: 2,
|
||||
isAdmin: true
|
||||
isAdmin: true,
|
||||
},
|
||||
{
|
||||
name: 'Imnotadmin',
|
||||
age: 35,
|
||||
isAdmin: false
|
||||
isAdmin: false,
|
||||
},
|
||||
{
|
||||
name: 'Wowsomuchadmin',
|
||||
age: 3634,
|
||||
isAdmin: true
|
||||
isAdmin: true,
|
||||
},
|
||||
])
|
||||
})
|
||||
]);
|
||||
});
|
||||
|
||||
const addUser = function addUser(user) {
|
||||
users.set([...getValue(users), user])
|
||||
}
|
||||
users.set([...getValue(users), user]);
|
||||
};
|
||||
|
||||
export {
|
||||
users,
|
||||
addUser
|
||||
}
|
||||
export { users, addUser };
|
||||
|
|
Loading…
Reference in a new issue