Skip to content

Commit e6913f5

Browse files
chore(remix-example): update for v2 (SAP#6455)
1 parent bccb13f commit e6913f5

File tree

4 files changed

+32
-25
lines changed

4 files changed

+32
-25
lines changed

examples/remix-ts/app/components/AppShellBar.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1+
import { useLocation, useNavigate } from '@remix-run/react';
2+
import { getTheme, setTheme } from '@ui5/webcomponents-base/dist/config/Theme.js';
13
import navBackIcon from '@ui5/webcomponents-icons/dist/nav-back.js';
24
import paletteIcon from '@ui5/webcomponents-icons/dist/palette.js';
35
import {
46
Button,
57
List,
6-
ListMode,
8+
ListItemStandard,
79
ListPropTypes,
810
ResponsivePopover,
911
ResponsivePopoverDomRef,
1012
ShellBar,
1113
ShellBarItem,
12-
ShellBarItemPropTypes,
13-
StandardListItem
14+
ShellBarItemPropTypes
1415
} from '@ui5/webcomponents-react';
16+
import ListSelectionMode from '@ui5/webcomponents/dist/types/ListSelectionMode.js';
1517
import { useRef, useState } from 'react';
1618
import classes from './AppShellBar.module.css';
17-
import { getTheme, setTheme } from '@ui5/webcomponents-base/dist/config/Theme.js';
18-
import { useLocation, useNavigate } from '@remix-run/react';
1919

2020
const THEMES = [
2121
{ key: 'sap_horizon', value: 'Morning Horizon (Light)' },
@@ -31,7 +31,10 @@ export function AppShellBar() {
3131
const [currentTheme, setCurrentTheme] = useState(getTheme);
3232

3333
const handleThemeSwitchItemClick: ShellBarItemPropTypes['onClick'] = (e) => {
34-
popoverRef.current?.showAt(e.detail.targetRef);
34+
if (popoverRef.current) {
35+
popoverRef.current.opener = e.detail.targetRef;
36+
popoverRef.current.open = true;
37+
}
3538
};
3639
const handleThemeSwitch: ListPropTypes['onSelectionChange'] = (e) => {
3740
const { targetItem } = e.detail;
@@ -58,11 +61,11 @@ export function AppShellBar() {
5861
<ShellBarItem icon={paletteIcon} text="Change Theme" onClick={handleThemeSwitchItemClick} />
5962
</ShellBar>
6063
<ResponsivePopover ref={popoverRef} className={classes.popover}>
61-
<List onSelectionChange={handleThemeSwitch} headerText="Change Theme" mode={ListMode.SingleSelect}>
64+
<List onSelectionChange={handleThemeSwitch} headerText="Change Theme" selectionMode={ListSelectionMode.Single}>
6265
{THEMES.map((theme) => (
63-
<StandardListItem key={theme.key} selected={currentTheme === theme.key} data-key={theme.key}>
66+
<ListItemStandard key={theme.key} selected={currentTheme === theme.key} data-key={theme.key}>
6467
{theme.value}
65-
</StandardListItem>
68+
</ListItemStandard>
6669
))}
6770
</List>
6871
</ResponsivePopover>

examples/remix-ts/app/components/TodoList.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { useNavigate } from '@remix-run/react';
2-
import { List, ListItemType, ListPropTypes, StandardListItem, ValueState } from '@ui5/webcomponents-react';
2+
import ValueState from '@ui5/webcomponents-base/dist/types/ValueState.js';
3+
import { List, ListItemStandard, ListPropTypes } from '@ui5/webcomponents-react';
4+
import ListItemType from '@ui5/webcomponents/dist/types/ListItemType.js';
35
import { Todo } from '~/mockData/todos';
46

57
interface TodoListProps {
@@ -16,15 +18,15 @@ export function TodoList({ items }: TodoListProps) {
1618
<List onItemClick={handleTodoClick}>
1719
{items.map((todo) => {
1820
return (
19-
<StandardListItem
21+
<ListItemStandard
2022
key={todo.id}
2123
data-id={todo.id}
2224
type={ListItemType.Navigation}
2325
additionalText={`${!todo.completed ? 'Not ' : ''}Completed`}
24-
additionalTextState={todo.completed ? ValueState.Success : ValueState.None}
26+
additionalTextState={todo.completed ? ValueState.Positive : ValueState.None}
2527
>
2628
{todo.title}
27-
</StandardListItem>
29+
</ListItemStandard>
2830
);
2931
})}
3032
</List>

examples/remix-ts/app/routes/_index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { MetaFunction } from '@remix-run/node';
2+
import { json } from '@remix-run/node';
23
import { useLoaderData } from '@remix-run/react';
34
import { Bar, Page, Title } from '@ui5/webcomponents-react';
4-
import { Todo, todos } from '~/mockData/todos';
5-
import { json } from '@remix-run/node';
65
import { TodoList } from '~/components/TodoList';
6+
import { Todo, todos } from '~/mockData/todos';
77

88
export const meta: MetaFunction = () => {
99
return [{ title: 'New Remix App' }, { name: 'description', content: 'Welcome to Remix!' }];
@@ -24,7 +24,7 @@ export default function Index() {
2424
data: { todos }
2525
} = useLoaderData<typeof loader>();
2626
return (
27-
<Page header={<Bar startContent={<Title>My Todos</Title>} />}>
27+
<Page header={<Bar style={{ paddingInline: 0 }} startContent={<Title>My Todos</Title>} />}>
2828
<TodoList items={todos} />
2929
</Page>
3030
);

examples/remix-ts/app/routes/todos.$id.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LoaderFunctionArgs, json } from '@remix-run/node';
1+
import { json, LoaderFunctionArgs } from '@remix-run/node';
22
import { useLoaderData } from '@remix-run/react';
33
import {
44
DatePicker,
@@ -7,11 +7,13 @@ import {
77
Form,
88
FormItem,
99
Input,
10+
Label,
1011
MessageStrip,
11-
MessageStripDesign,
1212
Switch,
13-
TextArea
13+
TextArea,
14+
Title
1415
} from '@ui5/webcomponents-react';
16+
import MessageStripDesign from '@ui5/webcomponents/dist/types/MessageStripDesign.js';
1517
import { Todo, todos } from '~/mockData/todos';
1618

1719
export const loader = async ({ params }: LoaderFunctionArgs) => {
@@ -31,22 +33,22 @@ export default function TodoDetails() {
3133

3234
return (
3335
<>
34-
<DynamicPage showHideHeaderButton={false} headerTitle={<DynamicPageTitle header={todo?.title} />}>
36+
<DynamicPage titleArea={<DynamicPageTitle heading={<Title>{todo?.title}</Title>} />}>
3537
<MessageStrip design={MessageStripDesign.Information}>
3638
{`Since this is only a demo app, adjustments made here on this page won't be reflected in the todo list.`}
3739
</MessageStrip>
3840
<Form>
39-
<FormItem label={'Title'}>
41+
<FormItem labelContent={<Label>Title</Label>}>
4042
<Input value={todo?.title} />
4143
</FormItem>
42-
<FormItem label={'Details'}>
43-
<TextArea value={todo?.details} growing growingMaxLines={10} />
44+
<FormItem labelContent={<Label>Details</Label>}>
45+
<TextArea value={todo?.details} growing growingMaxRows={10} />
4446
</FormItem>
4547

46-
<FormItem label={'Due Date'}>
48+
<FormItem labelContent={<Label>Due Date</Label>}>
4749
<DatePicker />
4850
</FormItem>
49-
<FormItem label={'Completed'}>
51+
<FormItem labelContent={<Label>Completed</Label>}>
5052
<Switch checked={todo?.completed} />
5153
</FormItem>
5254
</Form>

0 commit comments

Comments
 (0)