mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-08 17:16:25 +01:00
Put names into every export
This commit is contained in:
parent
c026635221
commit
665b908698
16 changed files with 67 additions and 40 deletions
|
@ -9,7 +9,7 @@ import store from '../utils/store';
|
||||||
import Avatar from './avatar';
|
import Avatar from './avatar';
|
||||||
import NameText from './name-text';
|
import NameText from './name-text';
|
||||||
|
|
||||||
export default ({ account }) => {
|
function Account({ account }) {
|
||||||
const [uiState, setUIState] = useState('default');
|
const [uiState, setUIState] = useState('default');
|
||||||
const isString = typeof account === 'string';
|
const isString = typeof account === 'string';
|
||||||
const [info, setInfo] = useState(isString ? null : account);
|
const [info, setInfo] = useState(isString ? null : account);
|
||||||
|
@ -181,4 +181,6 @@ export default ({ account }) => {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default Account;
|
||||||
|
|
|
@ -8,7 +8,7 @@ const SIZES = {
|
||||||
xxl: 50,
|
xxl: 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ({ url, size, alt = '' }) => {
|
function Avatar({ url, size, alt = '' }) {
|
||||||
size = SIZES[size] || size || SIZES.m;
|
size = SIZES[size] || size || SIZES.m;
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
|
@ -24,4 +24,6 @@ export default ({ url, size, alt = '' }) => {
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default Avatar;
|
||||||
|
|
|
@ -43,7 +43,7 @@ const ICONS = {
|
||||||
plus: 'mingcute:add-circle-line',
|
plus: 'mingcute:add-circle-line',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ({ icon, size = 'm', alt, title, class: className = '' }) => {
|
function Icon({ icon, size = 'm', alt, title, class: className = '' }) {
|
||||||
if (!icon) return null;
|
if (!icon) return null;
|
||||||
|
|
||||||
const iconSize = SIZES[size];
|
const iconSize = SIZES[size];
|
||||||
|
@ -74,4 +74,6 @@ export default ({ icon, size = 'm', alt, title, class: className = '' }) => {
|
||||||
</iconify-icon>
|
</iconify-icon>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default Icon;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import './loader.css';
|
import './loader.css';
|
||||||
|
|
||||||
export default ({ abrupt, hidden }) => (
|
function Loader({ abrupt, hidden }) {
|
||||||
|
return (
|
||||||
<div
|
<div
|
||||||
class={`loader-container ${abrupt ? 'abrupt' : ''} ${
|
class={`loader-container ${abrupt ? 'abrupt' : ''} ${
|
||||||
hidden ? 'hidden' : ''
|
hidden ? 'hidden' : ''
|
||||||
|
@ -9,3 +10,6 @@ export default ({ abrupt, hidden }) => (
|
||||||
<div class="loader" />
|
<div class="loader" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Loader;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { createPortal } from 'preact/compat';
|
||||||
|
|
||||||
const $modalContainer = document.getElementById('modal-container');
|
const $modalContainer = document.getElementById('modal-container');
|
||||||
|
|
||||||
export default ({ children, onClick, class: className }) => {
|
function Modal({ children, onClick, class: className }) {
|
||||||
if (!children) return null;
|
if (!children) return null;
|
||||||
|
|
||||||
const Modal = (
|
const Modal = (
|
||||||
|
@ -16,4 +16,6 @@ export default ({ children, onClick, class: className }) => {
|
||||||
return createPortal(Modal, $modalContainer);
|
return createPortal(Modal, $modalContainer);
|
||||||
|
|
||||||
// return createPortal(children, $modalContainer);
|
// return createPortal(children, $modalContainer);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default Modal;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import states from '../utils/states';
|
||||||
|
|
||||||
import Avatar from './avatar';
|
import Avatar from './avatar';
|
||||||
|
|
||||||
export default ({ account, showAvatar, showAcct, short, external }) => {
|
function NameText({ account, showAvatar, showAcct, short, external }) {
|
||||||
const { acct, avatar, avatarStatic, id, url, displayName, username, emojis } =
|
const { acct, avatar, avatarStatic, id, url, displayName, username, emojis } =
|
||||||
account;
|
account;
|
||||||
|
|
||||||
|
@ -55,4 +55,6 @@ export default ({ account, showAvatar, showAcct, short, external }) => {
|
||||||
)}
|
)}
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default NameText;
|
||||||
|
|
|
@ -11,7 +11,7 @@ import store from '../utils/store';
|
||||||
|
|
||||||
const LIMIT = 20;
|
const LIMIT = 20;
|
||||||
|
|
||||||
export default ({ hidden }) => {
|
function Home({ hidden }) {
|
||||||
const snapStates = useSnapshot(states);
|
const snapStates = useSnapshot(states);
|
||||||
const [uiState, setUIState] = useState('default');
|
const [uiState, setUIState] = useState('default');
|
||||||
const [showMore, setShowMore] = useState(false);
|
const [showMore, setShowMore] = useState(false);
|
||||||
|
@ -215,4 +215,6 @@ export default ({ hidden }) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default Home;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { getAuthorizationURL, registerApplication } from '../utils/auth';
|
||||||
import store from '../utils/store';
|
import store from '../utils/store';
|
||||||
import useTitle from '../utils/useTitle';
|
import useTitle from '../utils/useTitle';
|
||||||
|
|
||||||
export default () => {
|
function Login() {
|
||||||
useTitle('Log in');
|
useTitle('Log in');
|
||||||
const instanceURLRef = useRef();
|
const instanceURLRef = useRef();
|
||||||
const cachedInstanceURL = store.local.get('instanceURL');
|
const cachedInstanceURL = store.local.get('instanceURL');
|
||||||
|
@ -96,4 +96,6 @@ export default () => {
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default Login;
|
||||||
|
|
|
@ -187,7 +187,7 @@ function NotificationsList({ notifications, emptyCopy }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default () => {
|
function Notifications() {
|
||||||
useTitle('Notifications');
|
useTitle('Notifications');
|
||||||
const snapStates = useSnapshot(states);
|
const snapStates = useSnapshot(states);
|
||||||
const [uiState, setUIState] = useState('default');
|
const [uiState, setUIState] = useState('default');
|
||||||
|
@ -271,7 +271,6 @@ export default () => {
|
||||||
{ today: [], yesterday: [], older: [] },
|
{ today: [], yesterday: [], older: [] },
|
||||||
);
|
);
|
||||||
// console.log(groupedNotifications);
|
// console.log(groupedNotifications);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="deck-container" ref={scrollableRef}>
|
<div class="deck-container" ref={scrollableRef}>
|
||||||
<div class="timeline-deck deck">
|
<div class="timeline-deck deck">
|
||||||
|
@ -371,4 +370,6 @@ export default () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default Notifications;
|
||||||
|
|
|
@ -13,7 +13,7 @@ import store from '../utils/store';
|
||||||
- Dark/light/auto theme switch (done with adding/removing 'is-light' or 'is-dark' class on the body)
|
- Dark/light/auto theme switch (done with adding/removing 'is-light' or 'is-dark' class on the body)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default ({ onClose }) => {
|
function Settings({ onClose }) {
|
||||||
// Accounts
|
// Accounts
|
||||||
const accounts = store.local.getJSON('accounts');
|
const accounts = store.local.getJSON('accounts');
|
||||||
const currentAccount = store.session.get('currentAccount');
|
const currentAccount = store.session.get('currentAccount');
|
||||||
|
@ -206,4 +206,6 @@ export default ({ onClose }) => {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default Settings;
|
||||||
|
|
|
@ -14,7 +14,7 @@ import Status from '../components/status';
|
||||||
import states from '../utils/states';
|
import states from '../utils/states';
|
||||||
import useTitle from '../utils/useTitle';
|
import useTitle from '../utils/useTitle';
|
||||||
|
|
||||||
export default ({ id }) => {
|
function StatusPage({ id }) {
|
||||||
const snapStates = useSnapshot(states);
|
const snapStates = useSnapshot(states);
|
||||||
const [statuses, setStatuses] = useState([{ id }]);
|
const [statuses, setStatuses] = useState([{ id }]);
|
||||||
const [uiState, setUIState] = useState('default');
|
const [uiState, setUIState] = useState('default');
|
||||||
|
@ -215,4 +215,6 @@ export default ({ id }) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default StatusPage;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import './welcome.css';
|
||||||
import logo from '../assets/logo.svg';
|
import logo from '../assets/logo.svg';
|
||||||
import useTitle from '../utils/useTitle';
|
import useTitle from '../utils/useTitle';
|
||||||
|
|
||||||
export default () => {
|
function Welcome() {
|
||||||
useTitle();
|
useTitle();
|
||||||
return (
|
return (
|
||||||
<main id="welcome" class="box">
|
<main id="welcome" class="box">
|
||||||
|
@ -44,4 +44,6 @@ export default () => {
|
||||||
</p>
|
</p>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default Welcome;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import emojifyText from './emojify-text';
|
||||||
|
|
||||||
const fauxDiv = document.createElement('div');
|
const fauxDiv = document.createElement('div');
|
||||||
|
|
||||||
export default (content, opts = {}) => {
|
function enhanceContent(content, opts = {}) {
|
||||||
const { emojis, postEnhanceDOM = () => {} } = opts;
|
const { emojis, postEnhanceDOM = () => {} } = opts;
|
||||||
let enhancedContent = content;
|
let enhancedContent = content;
|
||||||
const dom = document.createElement('div');
|
const dom = document.createElement('div');
|
||||||
|
@ -64,7 +64,7 @@ export default (content, opts = {}) => {
|
||||||
enhancedContent = dom.innerHTML;
|
enhancedContent = dom.innerHTML;
|
||||||
|
|
||||||
return enhancedContent;
|
return enhancedContent;
|
||||||
};
|
}
|
||||||
|
|
||||||
function extractTextNodes(dom) {
|
function extractTextNodes(dom) {
|
||||||
const textNodes = [];
|
const textNodes = [];
|
||||||
|
@ -80,3 +80,5 @@ function extractTextNodes(dom) {
|
||||||
}
|
}
|
||||||
return textNodes;
|
return textNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default enhanceContent;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
export default (html) => {
|
export default function htmlContentLength(html) {
|
||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
return div.innerText.length;
|
return div.innerText.length;
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export default (opts) => {
|
export default function openCompose(opts) {
|
||||||
const url = new URL('/compose/', window.location);
|
const url = new URL('/compose/', window.location);
|
||||||
const { width: screenWidth, height: screenHeight } = window.screen;
|
const { width: screenWidth, height: screenHeight } = window.screen;
|
||||||
const left = Math.max(0, (screenWidth - 600) / 2);
|
const left = Math.max(0, (screenWidth - 600) / 2);
|
||||||
|
@ -20,4 +20,4 @@ export default (opts) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return newWin;
|
return newWin;
|
||||||
};
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { useEffect } from 'preact/hooks';
|
||||||
|
|
||||||
const { VITE_CLIENT_NAME: CLIENT_NAME } = import.meta.env;
|
const { VITE_CLIENT_NAME: CLIENT_NAME } = import.meta.env;
|
||||||
|
|
||||||
export default (title) => {
|
export default function useTitle(title) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.title = title ? `${title} / ${CLIENT_NAME}` : CLIENT_NAME;
|
document.title = title ? `${title} / ${CLIENT_NAME}` : CLIENT_NAME;
|
||||||
}, [title]);
|
}, [title]);
|
||||||
};
|
}
|
||||||
|
|
Loading…
Reference in a new issue