From 5c37fe9c3114a941bca90aae4e32dcb42bcdb7e4 Mon Sep 17 00:00:00 2001 From: Sonny Date: Thu, 7 Nov 2024 00:29:58 +0100 Subject: [PATCH] refactor: remove all legacy files + comment/delete things that haven't yet migrated to mantine --- .babelrc | 3 - app/controllers/admin_controller.ts | 10 +- app/controllers/collections_controller.ts | 8 +- app/controllers/links_controller.ts | 6 +- .../shared_collections_controller.ts | 7 +- inertia/app/app.tsx | 4 +- .../components/common/dropdown/dropdown.tsx | 64 ----- .../common/dropdown/dropdown_container.tsx | 21 -- .../common/dropdown/dropdown_item.tsx | 31 --- .../common/dropdown/dropdown_label.tsx | 11 - inertia/components/common/form/_button.tsx | 31 --- inertia/components/common/form/_form.tsx | 10 - .../components/common/form/_form_field.tsx | 25 -- .../common/form/_form_field_error.tsx | 9 - inertia/components/common/form/_input.tsx | 27 -- inertia/components/common/form/checkbox.tsx | 55 ----- inertia/components/common/form/selector.tsx | 79 ------ inertia/components/common/form/textbox.tsx | 49 ---- inertia/components/common/icon_button.tsx | 22 -- ...age_switcher.tsx => language_switcher.tsx} | 0 inertia/components/common/legend.tsx | 8 - .../components/common/modal/_modal_body.tsx | 11 - .../common/modal/_modal_container.tsx | 24 -- .../components/common/modal/_modal_header.tsx | 20 -- .../common/modal/_modal_wrapper.tsx | 19 -- inertia/components/common/modal/modal.tsx | 67 ----- inertia/components/common/rounded_image.tsx | 15 -- inertia/components/common/table.tsx | 227 ----------------- inertia/components/common/tabs/tab_item.tsx | 24 -- inertia/components/common/tabs/tab_list.tsx | 10 - inertia/components/common/tabs/tab_panel.tsx | 12 - inertia/components/common/tabs/tabs.tsx | 42 ---- inertia/components/common/text_ellipsis.tsx | 20 -- ..._theme_switcher.tsx => theme_switcher.tsx} | 0 .../common/unstyled/unstyled_list.tsx | 12 - .../{mantine_user_card.tsx => user_card.tsx} | 0 .../collection/collection_container.tsx | 39 --- .../collection/header/collection_controls.tsx | 42 ---- .../header/collection_description.tsx | 18 -- .../collection/header/collection_header.tsx | 87 ------- .../item/collection_item.module.css | 0 .../collection/item/collection_item.tsx | 0 .../collection/list/collection_item.tsx | 57 ----- .../list/collection_list.module.css | 0 .../collection/list/collection_list.tsx | 62 ++--- .../list/collection_list_container.tsx | 11 - .../components/dashboard/dashboard_aside.tsx | 2 +- .../components/dashboard/dashboard_header.tsx | 0 .../components/dashboard/dashboard_navbar.tsx | 4 +- .../dashboard/dashboard_provider.tsx | 95 ------- .../favorite/favorite_list.module.css | 0 .../dashboard/favorite/favorite_list.tsx | 2 +- .../favorite/item/favorite_item.module.css | 0 .../dashboard/favorite/item/favorite_item.tsx | 0 .../components/dashboard/link/link_list.tsx | 38 --- inertia/components/dashboard/link/no_item.tsx | 66 ----- .../dashboard/link/no_link.module.css | 0 .../components/dashboard/link/no_link.tsx | 0 .../dashboard/search/no_search_result.tsx | 29 --- .../dashboard/search/search_modal.tsx | 155 ------------ .../dashboard/search/search_result_item.tsx | 123 ---------- .../dashboard/search/search_result_list.tsx | 52 ---- .../side_nav/favorite/favorite_container.tsx | 11 - .../favorite/favorite_dropdown_item.tsx | 33 --- .../side_nav/favorite/favorite_item.tsx | 69 ------ .../side_nav/favorite/favorite_list.tsx | 51 ---- .../dashboard/side_nav/nav_item.tsx | 31 --- .../dashboard/side_nav/side_navigation.tsx | 80 ------ .../dashboard/side_nav/user_card.tsx | 21 -- .../components/dashboard/swiper_handler.tsx | 10 - inertia/components/footer/footer.tsx | 74 +++--- inertia/components/footer/mantine_footer.tsx | 58 ----- inertia/components/form/form_collection.tsx | 90 ++++--- inertia/components/form/form_link.tsx | 103 ++++---- .../{mantine => }/components/home/feature.tsx | 2 +- .../components/home/feature_list.tsx | 2 +- inertia/components/lang_selector.tsx | 53 ---- inertia/components/layouts/_base_layout.tsx | 15 -- inertia/components/layouts/_theme_layout.tsx | 147 ----------- .../components/layouts/_transition_layout.tsx | 8 - inertia/components/layouts/content_layout.tsx | 38 --- .../components/layouts/dashboard_layout.tsx | 21 -- inertia/components/layouts/form_layout.tsx | 69 ------ .../layouts/legal_content_layout.tsx | 36 --- inertia/components/legal/legal_footer.tsx | 20 -- inertia/components/navbar/mantine_navbar.tsx | 116 --------- ...le_navbar.module.css => mobile.module.css} | 0 inertia/components/navbar/navbar.tsx | 220 ++++++++--------- inertia/components/quotes.tsx | 28 --- inertia/components/settings/profile.tsx | 66 ----- .../components/settings/settings_modal.tsx | 66 ----- inertia/components/theme_switcher.tsx | 24 -- inertia/components/visibilty/visibilty.tsx | 31 --- .../contexts/active_collection_context.tsx | 15 -- inertia/contexts/collections_context.ts | 20 -- inertia/contexts/dark_theme_context.tsx | 46 ---- inertia/contexts/favorites_context.ts | 16 -- inertia/contexts/global_hotkeys_context.ts | 17 -- inertia/hooks/use_click_outside.tsx | 22 -- inertia/hooks/use_dark_theme.tsx | 5 - .../{mantine => }/use_disable_overflow.ts | 0 inertia/hooks/use_favorites.tsx | 5 - inertia/hooks/use_global_hotkeys.tsx | 5 - inertia/hooks/use_is_mobile.tsx | 8 - inertia/hooks/use_local_storage.tsx | 30 --- inertia/hooks/use_modal.tsx | 18 -- inertia/hooks/viewport/use_media_query.tsx | 24 -- inertia/hooks/viewport/use_screen_type.tsx | 9 - .../_base_layout.tsx} | 2 +- inertia/layouts/content_layout.tsx | 33 +++ .../dashboard_layout.tsx} | 4 +- .../form_layout.tsx} | 10 +- inertia/lib/array.ts | 42 ---- inertia/lib/collection.ts | 28 --- inertia/lib/color.ts | 6 - inertia/lib/image.ts | 6 - .../collection/list/collection_list.tsx | 55 ----- .../form/mantine_form_collection.tsx | 91 ------- .../components/form/mantine_form_link.tsx | 110 --------- .../layouts/mantine_content_layout.tsx | 33 --- inertia/pages/admin/dashboard.tsx | 132 ---------- inertia/pages/collections/create.tsx | 5 +- inertia/pages/collections/delete.tsx | 5 +- inertia/pages/collections/edit.tsx | 5 +- inertia/pages/dashboard.tsx | 231 ++++++++---------- inertia/pages/home.tsx | 6 +- inertia/pages/links/create.tsx | 5 +- inertia/pages/links/delete.tsx | 5 +- inertia/pages/links/edit.tsx | 5 +- inertia/pages/mantine/collections/create.tsx | 42 ---- inertia/pages/mantine/collections/delete.tsx | 42 ---- inertia/pages/mantine/collections/edit.tsx | 51 ---- inertia/pages/mantine/links/create.tsx | 51 ---- inertia/pages/mantine/links/delete.tsx | 37 --- inertia/pages/mantine/links/edit.tsx | 59 ----- inertia/pages/mantine_dashboard.tsx | 122 --------- inertia/pages/privacy.tsx | 6 +- inertia/pages/shared.tsx | 24 -- inertia/pages/terms.tsx | 6 +- inertia/styles/border.ts | 5 - inertia/styles/common_colors.ts | 9 - inertia/styles/keyframes.ts | 30 --- inertia/styles/media_queries.ts | 10 - inertia/styles/themes/dark_theme.ts | 45 ---- inertia/styles/themes/light_theme.ts | 46 ---- inertia/styles/transition.ts | 5 - inertia/tsconfig.json | 41 ++-- inertia/types/emotion.d.ts | 49 ---- 148 files changed, 469 insertions(+), 4728 deletions(-) delete mode 100644 .babelrc delete mode 100644 inertia/components/common/dropdown/dropdown.tsx delete mode 100644 inertia/components/common/dropdown/dropdown_container.tsx delete mode 100644 inertia/components/common/dropdown/dropdown_item.tsx delete mode 100644 inertia/components/common/dropdown/dropdown_label.tsx delete mode 100644 inertia/components/common/form/_button.tsx delete mode 100644 inertia/components/common/form/_form.tsx delete mode 100644 inertia/components/common/form/_form_field.tsx delete mode 100644 inertia/components/common/form/_form_field_error.tsx delete mode 100644 inertia/components/common/form/_input.tsx delete mode 100644 inertia/components/common/form/checkbox.tsx delete mode 100644 inertia/components/common/form/selector.tsx delete mode 100644 inertia/components/common/form/textbox.tsx delete mode 100644 inertia/components/common/icon_button.tsx rename inertia/components/common/{mantine_language_switcher.tsx => language_switcher.tsx} (100%) delete mode 100644 inertia/components/common/legend.tsx delete mode 100644 inertia/components/common/modal/_modal_body.tsx delete mode 100644 inertia/components/common/modal/_modal_container.tsx delete mode 100644 inertia/components/common/modal/_modal_header.tsx delete mode 100644 inertia/components/common/modal/_modal_wrapper.tsx delete mode 100644 inertia/components/common/modal/modal.tsx delete mode 100644 inertia/components/common/rounded_image.tsx delete mode 100644 inertia/components/common/table.tsx delete mode 100644 inertia/components/common/tabs/tab_item.tsx delete mode 100644 inertia/components/common/tabs/tab_list.tsx delete mode 100644 inertia/components/common/tabs/tab_panel.tsx delete mode 100644 inertia/components/common/tabs/tabs.tsx delete mode 100644 inertia/components/common/text_ellipsis.tsx rename inertia/components/common/{mantine_theme_switcher.tsx => theme_switcher.tsx} (100%) delete mode 100644 inertia/components/common/unstyled/unstyled_list.tsx rename inertia/components/common/{mantine_user_card.tsx => user_card.tsx} (100%) delete mode 100644 inertia/components/dashboard/collection/collection_container.tsx delete mode 100644 inertia/components/dashboard/collection/header/collection_controls.tsx delete mode 100644 inertia/components/dashboard/collection/header/collection_description.tsx delete mode 100644 inertia/components/dashboard/collection/header/collection_header.tsx rename inertia/{mantine => }/components/dashboard/collection/item/collection_item.module.css (100%) rename inertia/{mantine => }/components/dashboard/collection/item/collection_item.tsx (100%) delete mode 100644 inertia/components/dashboard/collection/list/collection_item.tsx rename inertia/{mantine => }/components/dashboard/collection/list/collection_list.module.css (100%) delete mode 100644 inertia/components/dashboard/collection/list/collection_list_container.tsx rename inertia/{mantine => }/components/dashboard/dashboard_aside.tsx (85%) rename inertia/{mantine => }/components/dashboard/dashboard_header.tsx (100%) rename inertia/{mantine => }/components/dashboard/dashboard_navbar.tsx (93%) delete mode 100644 inertia/components/dashboard/dashboard_provider.tsx rename inertia/{mantine => }/components/dashboard/favorite/favorite_list.module.css (100%) rename inertia/{mantine => }/components/dashboard/favorite/favorite_list.tsx (91%) rename inertia/{mantine => }/components/dashboard/favorite/item/favorite_item.module.css (100%) rename inertia/{mantine => }/components/dashboard/favorite/item/favorite_item.tsx (100%) delete mode 100644 inertia/components/dashboard/link/link_list.tsx delete mode 100644 inertia/components/dashboard/link/no_item.tsx rename inertia/{mantine => }/components/dashboard/link/no_link.module.css (100%) rename inertia/{mantine => }/components/dashboard/link/no_link.tsx (100%) delete mode 100644 inertia/components/dashboard/search/no_search_result.tsx delete mode 100644 inertia/components/dashboard/search/search_modal.tsx delete mode 100644 inertia/components/dashboard/search/search_result_item.tsx delete mode 100644 inertia/components/dashboard/search/search_result_list.tsx delete mode 100644 inertia/components/dashboard/side_nav/favorite/favorite_container.tsx delete mode 100644 inertia/components/dashboard/side_nav/favorite/favorite_dropdown_item.tsx delete mode 100644 inertia/components/dashboard/side_nav/favorite/favorite_item.tsx delete mode 100644 inertia/components/dashboard/side_nav/favorite/favorite_list.tsx delete mode 100644 inertia/components/dashboard/side_nav/nav_item.tsx delete mode 100644 inertia/components/dashboard/side_nav/side_navigation.tsx delete mode 100644 inertia/components/dashboard/side_nav/user_card.tsx delete mode 100644 inertia/components/dashboard/swiper_handler.tsx delete mode 100644 inertia/components/footer/mantine_footer.tsx rename inertia/{mantine => }/components/home/feature.tsx (94%) rename inertia/{mantine => }/components/home/feature_list.tsx (87%) delete mode 100644 inertia/components/lang_selector.tsx delete mode 100644 inertia/components/layouts/_base_layout.tsx delete mode 100644 inertia/components/layouts/_theme_layout.tsx delete mode 100644 inertia/components/layouts/_transition_layout.tsx delete mode 100644 inertia/components/layouts/content_layout.tsx delete mode 100644 inertia/components/layouts/dashboard_layout.tsx delete mode 100644 inertia/components/layouts/form_layout.tsx delete mode 100644 inertia/components/layouts/legal_content_layout.tsx delete mode 100644 inertia/components/legal/legal_footer.tsx delete mode 100644 inertia/components/navbar/mantine_navbar.tsx rename inertia/components/navbar/{mobile_navbar.module.css => mobile.module.css} (100%) delete mode 100644 inertia/components/quotes.tsx delete mode 100644 inertia/components/settings/profile.tsx delete mode 100644 inertia/components/settings/settings_modal.tsx delete mode 100644 inertia/components/theme_switcher.tsx delete mode 100644 inertia/components/visibilty/visibilty.tsx delete mode 100644 inertia/contexts/active_collection_context.tsx delete mode 100644 inertia/contexts/collections_context.ts delete mode 100644 inertia/contexts/dark_theme_context.tsx delete mode 100644 inertia/contexts/favorites_context.ts delete mode 100644 inertia/contexts/global_hotkeys_context.ts delete mode 100644 inertia/hooks/use_click_outside.tsx delete mode 100644 inertia/hooks/use_dark_theme.tsx rename inertia/hooks/{mantine => }/use_disable_overflow.ts (100%) delete mode 100644 inertia/hooks/use_favorites.tsx delete mode 100644 inertia/hooks/use_global_hotkeys.tsx delete mode 100644 inertia/hooks/use_is_mobile.tsx delete mode 100644 inertia/hooks/use_local_storage.tsx delete mode 100644 inertia/hooks/use_modal.tsx delete mode 100644 inertia/hooks/viewport/use_media_query.tsx delete mode 100644 inertia/hooks/viewport/use_screen_type.tsx rename inertia/{mantine/layouts/_mantine_base_layout.tsx => layouts/_base_layout.tsx} (97%) create mode 100644 inertia/layouts/content_layout.tsx rename inertia/{mantine/layouts/mantine_dashboard_layout.tsx => layouts/dashboard_layout.tsx} (55%) rename inertia/{mantine/layouts/mantine_form_layout.tsx => layouts/form_layout.tsx} (89%) delete mode 100644 inertia/lib/array.ts delete mode 100644 inertia/lib/collection.ts delete mode 100644 inertia/lib/color.ts delete mode 100644 inertia/lib/image.ts delete mode 100644 inertia/mantine/components/dashboard/collection/list/collection_list.tsx delete mode 100644 inertia/mantine/components/form/mantine_form_collection.tsx delete mode 100644 inertia/mantine/components/form/mantine_form_link.tsx delete mode 100644 inertia/mantine/layouts/mantine_content_layout.tsx delete mode 100644 inertia/pages/admin/dashboard.tsx delete mode 100644 inertia/pages/mantine/collections/create.tsx delete mode 100644 inertia/pages/mantine/collections/delete.tsx delete mode 100644 inertia/pages/mantine/collections/edit.tsx delete mode 100644 inertia/pages/mantine/links/create.tsx delete mode 100644 inertia/pages/mantine/links/delete.tsx delete mode 100644 inertia/pages/mantine/links/edit.tsx delete mode 100644 inertia/pages/mantine_dashboard.tsx delete mode 100644 inertia/pages/shared.tsx delete mode 100644 inertia/styles/border.ts delete mode 100644 inertia/styles/common_colors.ts delete mode 100644 inertia/styles/keyframes.ts delete mode 100644 inertia/styles/media_queries.ts delete mode 100644 inertia/styles/themes/dark_theme.ts delete mode 100644 inertia/styles/themes/light_theme.ts delete mode 100644 inertia/styles/transition.ts delete mode 100644 inertia/types/emotion.d.ts diff --git a/.babelrc b/.babelrc deleted file mode 100644 index ebdb6f7..0000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["@emotion"] -} diff --git a/app/controllers/admin_controller.ts b/app/controllers/admin_controller.ts index 0c4e3af..4d1b3b0 100644 --- a/app/controllers/admin_controller.ts +++ b/app/controllers/admin_controller.ts @@ -31,16 +31,22 @@ export default class AdminController { protected collectionsController: CollectionsController ) {} - async index({ inertia }: HttpContext) { + async index({ response }: HttpContext) { const users = await this.usersController.getAllUsersWithTotalRelations(); const linksCount = await this.linksController.getTotalLinksCount(); const collectionsCount = await this.collectionsController.getTotalCollectionsCount(); - return inertia.render('admin/dashboard', { + // TODO: return view + return response.json({ users: users.map((user) => new UserWithRelationCountDto(user).toJson()), totalLinks: linksCount, totalCollections: collectionsCount, }); + // return inertia.render('admin/dashboard', { + // users: users.map((user) => new UserWithRelationCountDto(user).toJson()), + // totalLinks: linksCount, + // totalCollections: collectionsCount, + // }); } } diff --git a/app/controllers/collections_controller.ts b/app/controllers/collections_controller.ts index ff38fad..39ccc18 100644 --- a/app/controllers/collections_controller.ts +++ b/app/controllers/collections_controller.ts @@ -26,7 +26,7 @@ export default class CollectionsController { } // TODO: Create DTOs - return inertia.render('mantine_dashboard', { + return inertia.render('dashboard', { collections: collections.map((collection) => collection.serialize()), activeCollection: activeCollection?.serialize() || collections[0].serialize(), @@ -36,7 +36,7 @@ export default class CollectionsController { // Create collection form async showCreatePage({ inertia, auth }: HttpContext) { const collections = await this.getCollectionsByAuthorId(auth.user!.id); - return inertia.render('mantine/collections/create', { + return inertia.render('collections/create', { disableHomeLink: collections.length === 0, }); } @@ -61,7 +61,7 @@ export default class CollectionsController { collectionId, auth.user!.id ); - return inertia.render('mantine/collections/edit', { + return inertia.render('collections/edit', { collection, }); } @@ -96,7 +96,7 @@ export default class CollectionsController { collectionId, auth.user!.id ); - return inertia.render('mantine/collections/delete', { + return inertia.render('collections/delete', { collection, }); } diff --git a/app/controllers/links_controller.ts b/app/controllers/links_controller.ts index 29f636f..ce36361 100644 --- a/app/controllers/links_controller.ts +++ b/app/controllers/links_controller.ts @@ -17,7 +17,7 @@ export default class LinksController { async showCreatePage({ auth, inertia }: HttpContext) { const collections = await this.collectionsController.getCollectionsByAuthorId(auth.user!.id); - return inertia.render('mantine/links/create', { collections }); + return inertia.render('links/create', { collections }); } async store({ auth, request, response }: HttpContext) { @@ -50,7 +50,7 @@ export default class LinksController { await this.collectionsController.getCollectionsByAuthorId(userId); const link = await this.getLinkById(linkId, userId); - return inertia.render('mantine/links/edit', { collections, link }); + return inertia.render('links/edit', { collections, link }); } async update({ request, auth, response }: HttpContext) { @@ -98,7 +98,7 @@ export default class LinksController { const link = await this.getLinkById(linkId, auth.user!.id); await link.load('collection'); - return inertia.render('mantine/links/delete', { link }); + return inertia.render('links/delete', { link }); } async delete({ request, auth, response }: HttpContext) { diff --git a/app/controllers/shared_collections_controller.ts b/app/controllers/shared_collections_controller.ts index 6354f96..fd2d971 100644 --- a/app/controllers/shared_collections_controller.ts +++ b/app/controllers/shared_collections_controller.ts @@ -4,13 +4,16 @@ import { getSharedCollectionValidator } from '#validators/shared_collection'; import type { HttpContext } from '@adonisjs/core/http'; export default class SharedCollectionsController { - async index({ request, inertia }: HttpContext) { + async index({ request, response }: HttpContext) { const { params } = await request.validateUsing( getSharedCollectionValidator ); const collection = await this.getSharedCollectionById(params.id); - return inertia.render('shared', { collection }); + console.log('shared page', collection); + // TODO: return view + return response.json(collection); + // return inertia.render('shared', { collection }); } private async getSharedCollectionById(id: Collection['id']) { diff --git a/inertia/app/app.tsx b/inertia/app/app.tsx index 67913ee..60c0d73 100644 --- a/inertia/app/app.tsx +++ b/inertia/app/app.tsx @@ -3,14 +3,12 @@ import { createInertiaApp } from '@inertiajs/react'; import 'dayjs/locale/en'; import 'dayjs/locale/fr'; import { hydrateRoot } from 'react-dom/client'; -import 'react-toggle/style.css'; -import { primaryColor } from '~/styles/common_colors'; import '../i18n/index'; const appName = import.meta.env.VITE_APP_NAME || 'MyLinks'; createInertiaApp({ - progress: { color: primaryColor }, + progress: { color: '#5474B4' }, title: (title) => `${appName}${title && ` - ${title}`}`, diff --git a/inertia/components/common/dropdown/dropdown.tsx b/inertia/components/common/dropdown/dropdown.tsx deleted file mode 100644 index fe8d28f..0000000 --- a/inertia/components/common/dropdown/dropdown.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import styled from '@emotion/styled'; -import { HtmlHTMLAttributes, ReactNode, useRef } from 'react'; -import DropdownContainer from '~/components/common/dropdown/dropdown_container'; -import DropdownLabel from '~/components/common/dropdown/dropdown_label'; -import useClickOutside from '~/hooks/use_click_outside'; -import useToggle from '~/hooks/use_modal'; -import useShortcut from '~/hooks/use_shortcut'; - -const DropdownStyle = styled.div<{ opened: boolean; svgSize?: number }>( - ({ opened, theme, svgSize = 24 }) => ({ - cursor: 'pointer', - userSelect: 'none', - position: 'relative', - minWidth: 'fit-content', - width: 'fit-content', - maxWidth: '250px', - backgroundColor: opened ? theme.colors.secondary : theme.colors.background, - padding: '4px', - borderRadius: theme.border.radius, - - '&:hover': { - backgroundColor: theme.colors.secondary, - }, - - '& svg': { - height: `${svgSize}px`, - width: `${svgSize}px`, - }, - }) -); - -export default function Dropdown({ - children, - label, - className, - svgSize, - onClick, -}: HtmlHTMLAttributes & { - label: ReactNode | string; - className?: string; - svgSize?: number; -}) { - const dropdownRef = useRef(null); - const { isShowing, toggle, close } = useToggle(); - - useClickOutside(dropdownRef, close); - useShortcut('ESCAPE_KEY', close, { disableGlobalCheck: true }); - - return ( - { - onClick?.(event); - toggle(); - }} - ref={dropdownRef} - className={className} - svgSize={svgSize} - > - {label} - {children} - - ); -} diff --git a/inertia/components/common/dropdown/dropdown_container.tsx b/inertia/components/common/dropdown/dropdown_container.tsx deleted file mode 100644 index 82c87e3..0000000 --- a/inertia/components/common/dropdown/dropdown_container.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import styled from '@emotion/styled'; -import TransitionLayout from '~/components/layouts/_transition_layout'; - -const DropdownContainer = styled(TransitionLayout)<{ show: boolean }>( - ({ show, theme }) => ({ - zIndex: 99, - position: 'absolute', - top: 'calc(100% + 0.5em)', - right: 0, - minWidth: '175px', - backgroundColor: show ? theme.colors.secondary : theme.colors.background, - border: `2px solid ${theme.colors.secondary}`, - borderRadius: theme.border.radius, - boxShadow: theme.colors.boxShadow, - display: show ? 'flex' : 'none', - flexDirection: 'column', - overflow: 'hidden', - }) -); - -export default DropdownContainer; diff --git a/inertia/components/common/dropdown/dropdown_item.tsx b/inertia/components/common/dropdown/dropdown_item.tsx deleted file mode 100644 index ed9e46b..0000000 --- a/inertia/components/common/dropdown/dropdown_item.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import styled from '@emotion/styled'; -import { Link } from '@inertiajs/react'; - -const DropdownItemBase = styled('div', { - shouldForwardProp: (propName) => propName !== 'danger', -})<{ danger?: boolean }>(({ theme, danger }) => ({ - fontSize: '14px', - whiteSpace: 'nowrap', - color: danger ? theme.colors.lightRed : theme.colors.primary, - padding: '8px 12px', - borderRadius: theme.border.radius, - - '&:hover': { - backgroundColor: theme.colors.background, - }, -})); - -const DropdownItemButton = styled(DropdownItemBase)({ - display: 'flex', - gap: '0.75em', - alignItems: 'center', -}); - -const DropdownItemLink = styled(DropdownItemBase.withComponent(Link))({ - width: '100%', - display: 'flex', - gap: '0.75em', - alignItems: 'center', -}); - -export { DropdownItemButton, DropdownItemLink }; diff --git a/inertia/components/common/dropdown/dropdown_label.tsx b/inertia/components/common/dropdown/dropdown_label.tsx deleted file mode 100644 index e1339d1..0000000 --- a/inertia/components/common/dropdown/dropdown_label.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import styled from '@emotion/styled'; - -const DropdownLabel = styled.div(({ theme }) => ({ - height: 'auto', - width: 'auto', - color: theme.colors.font, - display: 'flex', - gap: '0.35em', -})); - -export default DropdownLabel; diff --git a/inertia/components/common/form/_button.tsx b/inertia/components/common/form/_button.tsx deleted file mode 100644 index b41efeb..0000000 --- a/inertia/components/common/form/_button.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import styled from '@emotion/styled'; - -const Button = styled.button<{ danger?: boolean }>(({ theme, danger }) => { - const btnColor = !danger ? theme.colors.primary : theme.colors.lightRed; - const btnDarkColor = !danger ? theme.colors.darkBlue : theme.colors.lightRed; - return { - cursor: 'pointer', - width: '100%', - textTransform: 'uppercase', - fontSize: '14px', - color: theme.colors.white, - background: btnColor, - padding: '0.75em', - border: `1px solid ${btnColor}`, - borderRadius: theme.border.radius, - transition: theme.transition.delay, - - '&:disabled': { - cursor: 'not-allowed', - opacity: '0.5', - }, - - '&:not(:disabled):hover': { - boxShadow: `${btnDarkColor} 0 0 3px 1px`, - background: btnDarkColor, - color: theme.colors.white, - }, - }; -}); - -export default Button; diff --git a/inertia/components/common/form/_form.tsx b/inertia/components/common/form/_form.tsx deleted file mode 100644 index 4a88224..0000000 --- a/inertia/components/common/form/_form.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import styled from '@emotion/styled'; - -const Form = styled.form({ - width: '100%', - display: 'flex', - gap: '1em', - flexDirection: 'column', -}); - -export default Form; diff --git a/inertia/components/common/form/_form_field.tsx b/inertia/components/common/form/_form_field.tsx deleted file mode 100644 index d709557..0000000 --- a/inertia/components/common/form/_form_field.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import styled from '@emotion/styled'; - -const FormField = styled('div', { - shouldForwardProp: (propName) => propName !== 'required', -})<{ required?: boolean }>(({ required, theme }) => ({ - display: 'flex', - gap: '0.25em', - flexDirection: 'column', - - '& label': { - position: 'relative', - userSelect: 'none', - width: 'fit-content', - }, - - '& label::after': { - position: 'absolute', - top: 0, - right: '-0.75em', - color: theme.colors.lightRed, - content: (required ? '"*"' : '""') as any, - }, -})); - -export default FormField; diff --git a/inertia/components/common/form/_form_field_error.tsx b/inertia/components/common/form/_form_field_error.tsx deleted file mode 100644 index de3fb4d..0000000 --- a/inertia/components/common/form/_form_field_error.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import styled from '@emotion/styled'; - -// TODO: create a global style variable (fontSize) -const FormFieldError = styled.p(({ theme }) => ({ - fontSize: '12px', - color: theme.colors.lightRed, -})); - -export default FormFieldError; diff --git a/inertia/components/common/form/_input.tsx b/inertia/components/common/form/_input.tsx deleted file mode 100644 index cb0a1e0..0000000 --- a/inertia/components/common/form/_input.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import styled from '@emotion/styled'; - -const Input = styled.input(({ theme }) => ({ - width: '100%', - color: theme.colors.font, - backgroundColor: theme.colors.secondary, - padding: '0.75em', - border: `1px solid ${theme.colors.lightGrey}`, - borderBottom: `2px solid ${theme.colors.lightGrey}`, - borderRadius: theme.border.radius, - transition: theme.transition.delay, - - '&:focus': { - borderBottom: `2px solid ${theme.colors.primary}`, - }, - - '&:disabled': { - opacity: 0.85, - }, - - '&::placeholder': { - fontStyle: 'italic', - color: theme.colors.grey, - }, -})); - -export default Input; diff --git a/inertia/components/common/form/checkbox.tsx b/inertia/components/common/form/checkbox.tsx deleted file mode 100644 index 22f7038..0000000 --- a/inertia/components/common/form/checkbox.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { ChangeEvent, Fragment, InputHTMLAttributes, useState } from 'react'; -import Toggle from 'react-toggle'; -import FormField from '~/components/common/form/_form_field'; -import FormFieldError from '~/components/common/form/_form_field_error'; - -interface InputProps - extends Omit, 'onChange'> { - label: string; - name: string; - checked: boolean; - errors?: string[]; - onChange?: (name: string, checked: boolean) => void; -} - -export default function Checkbox({ - name, - label, - checked = false, - errors = [], - onChange, - required = false, - ...props -}: InputProps): JSX.Element { - const [checkboxChecked, setCheckboxChecked] = useState(checked); - - if (typeof window === 'undefined') return ; - - function _onChange({ target }: ChangeEvent) { - setCheckboxChecked(target.checked); - if (onChange) { - onChange(target.name, target.checked); - } - } - - return ( - - - - {errors.length > 0 && - errors.map((error) => {error})} - - ); -} diff --git a/inertia/components/common/form/selector.tsx b/inertia/components/common/form/selector.tsx deleted file mode 100644 index af49212..0000000 --- a/inertia/components/common/form/selector.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { useTheme } from '@emotion/react'; -import { InputHTMLAttributes, ReactNode, useEffect, useState } from 'react'; -import Select, { - FormatOptionLabelMeta, - GroupBase, - OptionsOrGroups, -} from 'react-select'; -import FormField from '~/components/common/form/_form_field'; - -type Option = { label: string | number; value: string | number }; - -interface SelectorProps - extends Omit, 'onChange'> { - label: string; - name: string; - errors?: string[]; - options: OptionsOrGroups>; - value: number | string; - onChangeCallback?: (value: number | string) => void; - formatOptionLabel?: ( - data: Option, - formatOptionLabelMeta: FormatOptionLabelMeta