Skip to content

Commit

Permalink
Refactor inset ion item (#1344)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeharding authored Mar 19, 2024
1 parent d1b076c commit c645b3b
Show file tree
Hide file tree
Showing 62 changed files with 343 additions and 358 deletions.
7 changes: 7 additions & 0 deletions src/core/globalCssOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export default css`
}
}
ion-list.list-inset ion-item {
--background: var(
--ion-tab-bar-background,
var(--ion-color-step-50, #fff)
);
}
.left-align-buttons
.action-sheet-button:not(.action-sheet-cancel)
.action-sheet-button-inner.sc-ion-action-sheet-ios:not(
Expand Down
11 changes: 5 additions & 6 deletions src/features/community/search/CommunitySearchResults.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IonLabel, IonList } from "@ionic/react";
import { IonItem, IonLabel, IonList } from "@ionic/react";
import { useBuildGeneralBrowseLink } from "../../../helpers/routes";
import { MaxWidthContainer } from "../../shared/AppContent";
import { InsetIonItem } from "../../settings/shared/formatting";

interface CommunitySearchResultsProps {
community: string;
Expand All @@ -17,24 +16,24 @@ export default function CommunitySearchResults({
return (
<MaxWidthContainer>
<IonList inset>
<InsetIonItem
<IonItem
routerLink={buildGeneralBrowseLink(
`/c/${community}/search/posts/${query}`,
)}
>
<IonLabel>
Search posts on c/{community} for “{query}
</IonLabel>
</InsetIonItem>
<InsetIonItem
</IonItem>
<IonItem
routerLink={buildGeneralBrowseLink(
`/c/${community}/search/comments/${query}`,
)}
>
<IonLabel>
Search comments on c/{community} for “{query}
</IonLabel>
</InsetIonItem>
</IonItem>
</IonList>
</MaxWidthContainer>
);
Expand Down
10 changes: 5 additions & 5 deletions src/features/migrate/MigrateList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
IonItem,
IonItemOption,
IonItemOptions,
IonItemSliding,
IonLabel,
IonList,
useIonAlert,
} from "@ionic/react";
import { InsetIonItem } from "../user/Profile";
import { useAppDispatch, useAppSelector } from "../../store";
import { useEffect } from "react";
import {
Expand Down Expand Up @@ -108,17 +108,17 @@ export default function MigrateList() {
Forget
</IonItemOption>
</IonItemOptions>
<InsetIonItem
<IonItem
routerLink={`/settings/reddit-migrate/${encodeURIComponent(link)}`}
>
<IonLabel class="ion-text-nowrap">{getPathname(link)}</IonLabel>
</InsetIonItem>
</IonItem>
</IonItemSliding>
))}
<IonItemSliding>
<InsetIonItem onClick={() => add()} button detail={false}>
<IonItem onClick={() => add()} button detail={false}>
<IonLabel color="primary">Add multireddit link</IonLabel>
</InsetIonItem>
</IonItem>
</IonItemSliding>
</IonList>
</>
Expand Down
7 changes: 3 additions & 4 deletions src/features/search/RandomCommunity.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IonIcon, IonLabel, IonList } from "@ionic/react";
import { InsetIonItem } from "../user/Profile";
import { IonIcon, IonItem, IonLabel, IonList } from "@ionic/react";
import { shuffle } from "ionicons/icons";
import { useAppSelector } from "../../store";

Expand All @@ -18,10 +17,10 @@ export default function RandomCommunity() {

return (
<IonList inset color="primary">
<InsetIonItem routerLink="/search/random">
<IonItem routerLink="/search/random">
<IonIcon icon={shuffle} color="primary" slot="start" />
<IonLabel className="ion-text-nowrap">Random Community</IonLabel>
</InsetIonItem>
</IonItem>
</IonList>
);
}
26 changes: 12 additions & 14 deletions src/features/search/SearchOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IonIcon, IonList } from "@ionic/react";
import { InsetIonItem, SettingLabel } from "../user/Profile";
import { IonIcon, IonItem, IonList } from "@ionic/react";
import { SettingLabel } from "../user/Profile";
import { useBuildGeneralBrowseLink } from "../../helpers/routes";
import {
albumsOutline,
Expand Down Expand Up @@ -36,41 +36,39 @@ export default function SearchOptions({ search }: SearchOptionsProps) {
<>
<IonList inset color="primary">
{type && !autoResolveType && (
<InsetIonItem
<IonItem
onClick={(e) => redirectToLemmyObjectIfNeeded(search, e)}
detail
button
>
<IonIcon icon={arrowForward} color="primary" />
<SettingLabel>Visit {type}</SettingLabel>
</InsetIonItem>
</IonItem>
)}
<InsetIonItem routerLink={`/search/posts/${searchURI}`}>
<IonItem routerLink={`/search/posts/${searchURI}`}>
<IonIcon icon={albumsOutline} color="primary" />
<SettingLabel className="ion-text-nowrap">
Posts with “{search}
</SettingLabel>
</InsetIonItem>
<InsetIonItem routerLink={`/search/comments/${searchURI}`}>
</IonItem>
<IonItem routerLink={`/search/comments/${searchURI}`}>
<IonIcon icon={chatbubbleOutline} color="primary" />
<SettingLabel className="ion-text-nowrap">
Comments with “{search}
</SettingLabel>
</InsetIonItem>
<InsetIonItem routerLink={`/search/communities/${searchURI}`}>
</IonItem>
<IonItem routerLink={`/search/communities/${searchURI}`}>
<IonIcon icon={searchOutline} color="primary" />
<SettingLabel className="ion-text-nowrap">
Communities with “{search}
</SettingLabel>
</InsetIonItem>
<InsetIonItem
routerLink={buildGeneralBrowseLink(`/u/${sanitizedUser}`)}
>
</IonItem>
<IonItem routerLink={buildGeneralBrowseLink(`/u/${sanitizedUser}`)}>
<IonIcon icon={personOutline} color="primary" />
<SettingLabel className="ion-text-nowrap">
Go to User “{search}
</SettingLabel>
</InsetIonItem>
</IonItem>
</IonList>
{autoResolveType && <AutoResolvePostComment url={search} />}
</>
Expand Down
13 changes: 9 additions & 4 deletions src/features/search/TrendingCommunities.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { IonIcon, IonLabel, IonList, IonListHeader } from "@ionic/react";
import {
IonIcon,
IonItem,
IonLabel,
IonList,
IonListHeader,
} from "@ionic/react";
import { useBuildGeneralBrowseLink } from "../../helpers/routes";
import { useAppDispatch, useAppSelector } from "../../store";
import { InsetIonItem } from "../user/Profile";
import { getHandle } from "../../helpers/lemmy";
import { trendingUp } from "ionicons/icons";
import { useEffect } from "react";
Expand Down Expand Up @@ -31,7 +36,7 @@ export default function TrendingCommunities() {
</IonLabel>
</IonListHeader>
{trendingCommunities?.map((community) => (
<InsetIonItem
<IonItem
routerLink={buildGeneralBrowseLink(
`/c/${getHandle(community.community)}`,
)}
Expand All @@ -41,7 +46,7 @@ export default function TrendingCommunities() {
<IonLabel className="ion-text-nowrap">
{getHandle(community.community)}
</IonLabel>
</InsetIonItem>
</IonItem>
))}
</IonList>
);
Expand Down
6 changes: 3 additions & 3 deletions src/features/settings/app-icon/AppIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
IonBadge,
IonItem,
IonLabel,
IonList,
IonRadio,
IonRadioGroup,
IonText,
IonThumbnail,
} from "@ionic/react";
import { InsetIonItem } from "../shared/formatting";
import { useAppDispatch, useAppSelector } from "../../../store";
import { APP_ICONS, AppIcon, updateAppIcon } from "./appIconSlice";
import { isAndroid } from "../../../helpers/device";
Expand Down Expand Up @@ -41,7 +41,7 @@ export default function AppIconComponent() {
<IonRadioGroup value={icon} onIonChange={(e) => selectIcon(e.detail.value)}>
<IonList inset>
{APP_ICONS.map((icon) => (
<InsetIonItem key={icon}>
<IonItem key={icon}>
<StyledIonThumbnail slot="start" onClick={() => selectIcon(icon)}>
<Img src={getIconSrc(icon)} />
</StyledIonThumbnail>
Expand All @@ -63,7 +63,7 @@ export default function AppIconComponent() {
</p>
</IonLabel>
</IonRadio>
</InsetIonItem>
</IonItem>
))}
</IonList>
</IonRadioGroup>
Expand Down
11 changes: 5 additions & 6 deletions src/features/settings/appearance/CompactSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IonLabel, IonList, IonToggle } from "@ionic/react";
import { InsetIonItem } from "../../user/Profile";
import { IonItem, IonLabel, IonList, IonToggle } from "@ionic/react";
import { useAppSelector, useAppDispatch } from "../../../store";
import {
setCompactShowSelfPostThumbnails,
Expand Down Expand Up @@ -44,7 +43,7 @@ export default function CompactSettings() {
setSelected={setThumbnailPosition}
options={OCompactThumbnailPositionType}
/>
<InsetIonItem>
<IonItem>
<IonToggle
checked={showVotingButtons}
onIonChange={(e) =>
Expand All @@ -53,8 +52,8 @@ export default function CompactSettings() {
>
Show Voting Buttons
</IonToggle>
</InsetIonItem>
<InsetIonItem>
</IonItem>
<IonItem>
<IonToggle
checked={showSelfPostThumbnails}
onIonChange={(e) =>
Expand All @@ -63,7 +62,7 @@ export default function CompactSettings() {
>
Show Self Post Thumbnails
</IonToggle>
</InsetIonItem>
</IonItem>
</IonList>
</>
);
Expand Down
7 changes: 3 additions & 4 deletions src/features/settings/appearance/LargeSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IonLabel, IonList, IonToggle } from "@ionic/react";
import { InsetIonItem } from "../../user/Profile";
import { IonItem, IonLabel, IonList, IonToggle } from "@ionic/react";
import { useAppSelector, useAppDispatch } from "../../../store";
import { setLargeShowVotingButtons } from "../settingsSlice";
import { ListHeader } from "../shared/formatting";
Expand All @@ -16,7 +15,7 @@ export default function LargeSettings() {
<IonLabel>Large Posts</IonLabel>
</ListHeader>
<IonList inset>
<InsetIonItem>
<IonItem>
<IonToggle
checked={showVotingButtons}
onIonChange={(e) =>
Expand All @@ -25,7 +24,7 @@ export default function LargeSettings() {
>
Show Voting Buttons
</IonToggle>
</InsetIonItem>
</IonItem>
</IonList>
</>
);
Expand Down
15 changes: 7 additions & 8 deletions src/features/settings/appearance/TextSize.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IonLabel, IonList, IonRange, IonToggle } from "@ionic/react";
import { InsetIonItem } from "../../../routes/pages/profile/ProfileFeedItemsPage";
import { IonItem, IonLabel, IonList, IonRange, IonToggle } from "@ionic/react";
import { useAppDispatch, useAppSelector } from "../../../store";
import { setFontSizeMultiplier, setUseSystemFontSize } from "../settingsSlice";
import { HelperText, ListHeader } from "../shared/formatting";
Expand Down Expand Up @@ -47,7 +46,7 @@ export default function TextSize() {
<IonLabel>Text size</IonLabel>
</ListHeader>
<IonList inset>
<InsetIonItem>
<IonItem>
<IonToggle
checked={useSystemFontSize}
onIonChange={(e) =>
Expand All @@ -56,8 +55,8 @@ export default function TextSize() {
>
Use System Text Size
</IonToggle>
</InsetIonItem>
<InsetIonItem>
</IonItem>
<IonItem>
<Range
disabled={useSystemFontSize}
ticks
Expand All @@ -73,9 +72,9 @@ export default function TextSize() {
</A>
<A slot="end">A</A>
</Range>
</InsetIonItem>
</IonItem>
{fontSizeMultiplier >= 1.4 && (
<InsetIonItem>
<IonItem>
<IonToggle
checked={fontSizeMultiplier > MAX_REGULAR_FONT_ADJUSTMENT}
onIonChange={() =>
Expand All @@ -90,7 +89,7 @@ export default function TextSize() {
>
Larger Text Mode
</IonToggle>
</InsetIonItem>
</IonItem>
)}
</IonList>
<HelperText>Default is two ticks from the left.</HelperText>
Expand Down
8 changes: 4 additions & 4 deletions src/features/settings/appearance/ThemesButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IonIcon, IonLabel, IonList } from "@ionic/react";
import { InsetIonItem, ListHeader } from "../shared/formatting";
import { IonIcon, IonItem, IonLabel, IonList } from "@ionic/react";
import { ListHeader } from "../shared/formatting";
import { IconBg } from "../../../routes/pages/settings/SettingsPage";
import { colorPalette } from "ionicons/icons";
import { SettingLabel } from "../../user/Profile";
Expand All @@ -11,12 +11,12 @@ export default function ThemesButton() {
<IonLabel>Themes</IonLabel>
</ListHeader>
<IonList inset>
<InsetIonItem routerLink="/settings/appearance/theme">
<IonItem routerLink="/settings/appearance/theme">
<IconBg color="color(display-p3 0.5 0 1)">
<IonIcon icon={colorPalette} />
</IconBg>
<SettingLabel>Themes</SettingLabel>
</InsetIonItem>
</IonItem>
</IonList>
</>
);
Expand Down
7 changes: 3 additions & 4 deletions src/features/settings/appearance/other/ShowUserInstance.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { IonToggle } from "@ionic/react";
import { IonItem, IonToggle } from "@ionic/react";
import { useAppDispatch, useAppSelector } from "../../../../store";
import { setUserInstanceUrlDisplay } from "../../settingsSlice";
import { OInstanceUrlDisplayMode } from "../../../../services/db";
import { InsetIonItem } from "../../shared/formatting";

export default function ShowUserInstance() {
const dispatch = useAppDispatch();
Expand All @@ -11,7 +10,7 @@ export default function ShowUserInstance() {
);

return (
<InsetIonItem>
<IonItem>
<IonToggle
checked={userInstanceUrlDisplay === OInstanceUrlDisplayMode.WhenRemote}
onIonChange={(e) =>
Expand All @@ -26,6 +25,6 @@ export default function ShowUserInstance() {
>
Show User Instance
</IonToggle>
</InsetIonItem>
</IonItem>
);
}
Loading

0 comments on commit c645b3b

Please sign in to comment.