1
0
Fork 0

Put names into every export

This commit is contained in:
Lim Chee Aun 2022-12-16 13:27:04 +08:00
parent c026635221
commit 665b908698
16 changed files with 67 additions and 40 deletions

View file

@ -9,7 +9,7 @@ import store from '../utils/store';
import Avatar from './avatar';
import NameText from './name-text';
export default ({ account }) => {
function Account({ account }) {
const [uiState, setUIState] = useState('default');
const isString = typeof account === 'string';
const [info, setInfo] = useState(isString ? null : account);
@ -181,4 +181,6 @@ export default ({ account }) => {
)}
</div>
);
};
}
export default Account;

View file

@ -8,7 +8,7 @@ const SIZES = {
xxl: 50,
};
export default ({ url, size, alt = '' }) => {
function Avatar({ url, size, alt = '' }) {
size = SIZES[size] || size || SIZES.m;
return (
<span
@ -24,4 +24,6 @@ export default ({ url, size, alt = '' }) => {
)}
</span>
);
};
}
export default Avatar;

View file

@ -43,7 +43,7 @@ const ICONS = {
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;
const iconSize = SIZES[size];
@ -74,4 +74,6 @@ export default ({ icon, size = 'm', alt, title, class: className = '' }) => {
</iconify-icon>
</div>
);
};
}
export default Icon;

View file

@ -1,11 +1,15 @@
import './loader.css';
export default ({ abrupt, hidden }) => (
<div
class={`loader-container ${abrupt ? 'abrupt' : ''} ${
hidden ? 'hidden' : ''
}`}
>
<div class="loader" />
</div>
);
function Loader({ abrupt, hidden }) {
return (
<div
class={`loader-container ${abrupt ? 'abrupt' : ''} ${
hidden ? 'hidden' : ''
}`}
>
<div class="loader" />
</div>
);
}
export default Loader;

View file

@ -4,7 +4,7 @@ import { createPortal } from 'preact/compat';
const $modalContainer = document.getElementById('modal-container');
export default ({ children, onClick, class: className }) => {
function Modal({ children, onClick, class: className }) {
if (!children) return null;
const Modal = (
@ -16,4 +16,6 @@ export default ({ children, onClick, class: className }) => {
return createPortal(Modal, $modalContainer);
// return createPortal(children, $modalContainer);
};
}
export default Modal;

View file

@ -5,7 +5,7 @@ import states from '../utils/states';
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 } =
account;
@ -55,4 +55,6 @@ export default ({ account, showAvatar, showAcct, short, external }) => {
)}
</a>
);
};
}
export default NameText;

View file

@ -11,7 +11,7 @@ import store from '../utils/store';
const LIMIT = 20;
export default ({ hidden }) => {
function Home({ hidden }) {
const snapStates = useSnapshot(states);
const [uiState, setUIState] = useState('default');
const [showMore, setShowMore] = useState(false);
@ -215,4 +215,6 @@ export default ({ hidden }) => {
</div>
</div>
);
};
}
export default Home;

View file

@ -6,7 +6,7 @@ import { getAuthorizationURL, registerApplication } from '../utils/auth';
import store from '../utils/store';
import useTitle from '../utils/useTitle';
export default () => {
function Login() {
useTitle('Log in');
const instanceURLRef = useRef();
const cachedInstanceURL = store.local.get('instanceURL');
@ -96,4 +96,6 @@ export default () => {
</form>
</main>
);
};
}
export default Login;

View file

@ -187,7 +187,7 @@ function NotificationsList({ notifications, emptyCopy }) {
);
}
export default () => {
function Notifications() {
useTitle('Notifications');
const snapStates = useSnapshot(states);
const [uiState, setUIState] = useState('default');
@ -271,7 +271,6 @@ export default () => {
{ today: [], yesterday: [], older: [] },
);
// console.log(groupedNotifications);
return (
<div class="deck-container" ref={scrollableRef}>
<div class="timeline-deck deck">
@ -371,4 +370,6 @@ export default () => {
</div>
</div>
);
};
}
export default Notifications;

View file

@ -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)
*/
export default ({ onClose }) => {
function Settings({ onClose }) {
// Accounts
const accounts = store.local.getJSON('accounts');
const currentAccount = store.session.get('currentAccount');
@ -206,4 +206,6 @@ export default ({ onClose }) => {
)}
</div>
);
};
}
export default Settings;

View file

@ -14,7 +14,7 @@ import Status from '../components/status';
import states from '../utils/states';
import useTitle from '../utils/useTitle';
export default ({ id }) => {
function StatusPage({ id }) {
const snapStates = useSnapshot(states);
const [statuses, setStatuses] = useState([{ id }]);
const [uiState, setUIState] = useState('default');
@ -215,4 +215,6 @@ export default ({ id }) => {
</div>
</div>
);
};
}
export default StatusPage;

View file

@ -3,7 +3,7 @@ import './welcome.css';
import logo from '../assets/logo.svg';
import useTitle from '../utils/useTitle';
export default () => {
function Welcome() {
useTitle();
return (
<main id="welcome" class="box">
@ -44,4 +44,6 @@ export default () => {
</p>
</main>
);
};
}
export default Welcome;

View file

@ -2,7 +2,7 @@ import emojifyText from './emojify-text';
const fauxDiv = document.createElement('div');
export default (content, opts = {}) => {
function enhanceContent(content, opts = {}) {
const { emojis, postEnhanceDOM = () => {} } = opts;
let enhancedContent = content;
const dom = document.createElement('div');
@ -64,7 +64,7 @@ export default (content, opts = {}) => {
enhancedContent = dom.innerHTML;
return enhancedContent;
};
}
function extractTextNodes(dom) {
const textNodes = [];
@ -80,3 +80,5 @@ function extractTextNodes(dom) {
}
return textNodes;
}
export default enhanceContent;

View file

@ -1,5 +1,5 @@
const div = document.createElement('div');
export default (html) => {
export default function htmlContentLength(html) {
div.innerHTML = html;
return div.innerText.length;
};
}

View file

@ -1,4 +1,4 @@
export default (opts) => {
export default function openCompose(opts) {
const url = new URL('/compose/', window.location);
const { width: screenWidth, height: screenHeight } = window.screen;
const left = Math.max(0, (screenWidth - 600) / 2);
@ -20,4 +20,4 @@ export default (opts) => {
}
return newWin;
};
}

View file

@ -2,8 +2,8 @@ import { useEffect } from 'preact/hooks';
const { VITE_CLIENT_NAME: CLIENT_NAME } = import.meta.env;
export default (title) => {
export default function useTitle(title) {
useEffect(() => {
document.title = title ? `${title} / ${CLIENT_NAME}` : CLIENT_NAME;
}, [title]);
};
}