Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add date picker and calendar #156

Merged
merged 7 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .changeset/bright-hornets-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@crossed/ui': minor
---

add calendar
5 changes: 5 additions & 0 deletions .changeset/khaki-seas-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@crossed/ui': minor
---

add date picker
4 changes: 4 additions & 0 deletions apps/crossed-native/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import SheetScreen from './src/app/sheet';
import TooltipScreen from './src/app/tooltip';
import { CrossedUIProvider } from '@crossed/ui';
import ModalScreen from './src/app/modal.tsx';
import CalendarScreen from './src/app/calendar.tsx';
import DateInputScreen from './src/app/dateInput.tsx';

const Stack = createNativeStackNavigator<RootStackParamList>();

Expand All @@ -44,6 +46,8 @@ function App(): React.JSX.Element {
<Stack.Screen name="/select" component={SelectScreen} />
<Stack.Screen name="/tooltip" component={TooltipScreen} />
<Stack.Screen name="/modal" component={ModalScreen} />
<Stack.Screen name="/calendar" component={CalendarScreen} />
<Stack.Screen name="/dateInput" component={DateInputScreen} />
</Stack.Navigator>
</NavigationContainer>
</SafeAreaView>
Expand Down
13 changes: 12 additions & 1 deletion apps/crossed-native/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: ["react-native-reanimated/plugin"]
plugins: [
'react-native-reanimated/plugin',
[
'module-resolver',
{
root: ['./src'],
alias: {
'react-native-gesture-handler': './node_modules/react-native-gesture-handler',
},
},
],
],
};
4 changes: 3 additions & 1 deletion apps/crossed-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@
"@crossed/ui": "6.4.8",
"@crossed/unicons": "workspace:*",
"@gorhom/portal": "^1.0.14",
"@react-native-community/cli": "^15.1.3",
"@react-native/gradle-plugin": "^0.75.3",
"@react-navigation/native": "^6.0.2",
"@react-navigation/native-stack": "^6.11.0",
"@rnx-kit/metro-config": "^1.3.3",
"@rnx-kit/metro-resolver-symlinks": "^0.1.22",
"babel-plugin-module-resolver": "^5.0.2",
"react": "18.3.1",
"react-native": "=0.75.2",
"react-native-gesture-handler": "~2.21.2",
"react-native-reanimated": "^3.10.1",
"react-native-safe-area-context": "4.10.8",
"react-native-safe-area-context": "5.2.0",
"react-native-screens": "^3.34.0",
"react-native-svg": "^15.1.0"
},
Expand Down
45 changes: 45 additions & 0 deletions apps/crossed-native/src/app/calendar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) Paymium.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root of this projects source tree.
*/

import { YBox, Calendar } from '@crossed/ui';
import { createStyles } from '@crossed/styled';
import { FlatList } from 'react-native';
import { Card } from '@crossed/ui';

const styles = createStyles(() => ({
scrollview: { base: { paddingHorizontal: 10, paddingVertical: 10 } },
between: {
base: {
width: '100%',
justifyContent: 'space-between',
},
},
end: { base: { alignSelf: 'flex-end', flexDirection: 'row' } },
}));

const Example = () => {
return (
<Card>
<Calendar />
</Card>
);
};

export default function CalendarScreen() {
return (
<FlatList
contentContainerStyle={styles.scrollview.rnw().style}
data={[]}
ListHeaderComponent={
<YBox alignItems="stretch" space="sm">
<Example />
</YBox>
}
renderItem={() => null}
/>
);
}
40 changes: 40 additions & 0 deletions apps/crossed-native/src/app/dateInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) Paymium.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root of this projects source tree.
*/

import { YBox, DateInput } from '@crossed/ui';
import { createStyles } from '@crossed/styled';
import { FlatList } from 'react-native';

const styles = createStyles(() => ({
scrollview: { base: { paddingHorizontal: 10, paddingVertical: 10 } },
between: {
base: {
width: '100%',
justifyContent: 'space-between',
},
},
end: { base: { alignSelf: 'flex-end', flexDirection: 'row' } },
}));

const Example = () => {
return <DateInput picker />;
};

export default function DateInputScreen() {
return (
<FlatList
contentContainerStyle={styles.scrollview.rnw().style}
data={[]}
ListHeaderComponent={
<YBox alignItems="stretch" space="sm">
<Example />
</YBox>
}
renderItem={() => null}
/>
);
}
2 changes: 2 additions & 0 deletions apps/crossed-native/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const menus: Menu[] = [
{ to: '/sheet', title: 'Sheet' },
{ to: '/tooltip', title: 'Tooltip' },
{ to: '/modal', title: 'Modal' },
{ to: '/calendar', title: 'Calendar' },
{ to: '/dateInput', title: 'DateInput' },
] as const;

export default function TabOneScreen({ navigation }: IndexScreenProps) {
Expand Down
2 changes: 2 additions & 0 deletions apps/crossed-native/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export type RootStackParamList = {
'/sheet': undefined;
'/tooltip': undefined;
'/modal': undefined;
'/calendar': undefined;
'/dateInput': undefined;
};

export type AccordionScreenProps = NativeStackScreenProps<
Expand Down
52 changes: 52 additions & 0 deletions apps/doc/src/@crossed-ui/Forms/Calendar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (c) Paymium.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root of this projects source tree.
*/

import type { Meta, StoryObj } from '@storybook/react';
import { fn } from '@storybook/test';

import { Calendar } from '@crossed/ui/src/forms/Calendar';
import { Card } from '@crossed/ui/src/display/Card';

const date = new Date();
const first = new Date(date);
const last = new Date(date);
first.setFullYear(date.getFullYear() - 50);
last.setFullYear(date.getFullYear() + 50);

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta: Meta<typeof Calendar> = {
component: Calendar,
tags: ['autodocs'],
parameters: { layout: 'centered' },
argTypes: {
locale: { control: 'radio', options: ['en', 'fr', 'default'] },
},
args: {
firstDayOfWeek: 1,
minDate: first,
maxDate: last,
monthsToDisplay: 1,
onDateSelected: fn(),
// selectedDate: date,
locale: 'default',
},
render(e) {
return (
<Card>
<Calendar {...e} />
</Card>
);
},
};

export default meta;
type Story = StoryObj<typeof Calendar>;

// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Primary: Story = {
args: {},
};
39 changes: 39 additions & 0 deletions apps/doc/src/@crossed-ui/Forms/DateInput.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright (c) Paymium.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root of this projects source tree.
*/

import type { Meta, StoryObj } from '@storybook/react';
import { fn } from '@storybook/test';

import { DateInput } from '@crossed/ui/src/forms/DateInput';
// import { Text } from '@crossed/ui';

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta: Meta<typeof DateInput> = {
component: DateInput,
tags: ['autodocs'],
parameters: { layout: 'centered' },
argTypes: {
locale: { control: 'select', options: ['default', 'en', 'fr'] },
format: { control: 'text', value: 'yyyy-mm-dd' },
},
args: { locale: 'default', onChange: fn() },
};

export default meta;
type Story = StoryObj<typeof DateInput>;

// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Primary: Story = { args: {} };

export const WithPlaceholder: Story = {
args: {
placeholder: { day: 'day (dd)', month: 'month (mm)', year: 'year (yyyy)' },
},
};
export const WithPicker: Story = { args: { picker: true } };
export const WithValue: Story = { args: { value: new Date() } };
export const OnlyYearMonth: Story = { args: { format: 'yyyy-mm' } };
Loading
Loading