Skip to content

Commit 2d74f9e

Browse files
Merge pull request #5 from react-declarative/typography-field
typography
2 parents 6130e93 + e8fb848 commit 2d74f9e

File tree

21 files changed

+185
-21
lines changed

21 files changed

+185
-21
lines changed

demo/package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"react-native": "0.74.1",
1111
"react-native-svg": "15.2.0",
1212
"react-native-web": "~0.19.6",
13-
"rn-declarative": "^0.0.55",
14-
"rn-declarative-eva": "^0.0.43"
13+
"rn-declarative": "^0.0.56",
14+
"rn-declarative-eva": "^0.0.44"
1515
},
1616
"devDependencies": {
1717
"@babel/core": "^7.19.3",

packages/rn-declarative-eva/package-lock.json

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/rn-declarative-eva/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rn-declarative-eva",
3-
"version": "0.0.43",
3+
"version": "0.0.44",
44
"description": "A responsive layout for the react-native",
55
"private": false,
66
"author": {
@@ -77,7 +77,7 @@
7777
"react-native": "0.71.6",
7878
"react-native-svg": "9.4.0",
7979
"typescript": "4.6.2",
80-
"rn-declarative": "0.0.55"
80+
"rn-declarative": "0.0.56"
8181
},
8282
"dependencies": {
8383
"rimraf": "3.0.2"

packages/rn-declarative/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/rn-declarative/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rn-declarative",
3-
"version": "0.0.55",
3+
"version": "0.0.56",
44
"description": "A responsive layout for the react-native",
55
"private": false,
66
"author": {

packages/rn-declarative/src/components/One/components/SlotFactory/ISlotFactoryContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { IRatingSlot } from '../../slots/RatingSlot';
1616
import { ISliderSlot } from '../../slots/SliderSlot';
1717
import { ITimeSlot } from '../../slots/TimeSlot';
1818
import { IChooseSlot } from '../../slots/ChooseSlot';
19+
import { ITypographySlot } from '../../slots/TypographySlot';
1920

2021
/**
2122
* A context object that provides access to various component types used by the slot factory.
@@ -45,6 +46,7 @@ export interface ISlotFactoryContext {
4546
Slider: ComponentType<ISliderSlot>;
4647
Time: ComponentType<ITimeSlot>;
4748
Choose: ComponentType<IChooseSlot>;
49+
Typography: ComponentType<ITypographySlot>;
4850
}
4951

5052
export default ISlotFactoryContext;

packages/rn-declarative/src/components/One/components/SlotFactory/SlotContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Rating from './components/Rating';
1616
import Slider from './components/Slider';
1717
import Time from './components/Time';
1818
import Choose from './components/Choose';
19+
import Typography from './components/Typography';
1920

2021
import ISlotFactoryContext from './ISlotFactoryContext';
2122

@@ -46,6 +47,7 @@ export const defaultSlots: ISlotFactoryContext = {
4647
Slider,
4748
Time,
4849
Choose,
50+
Typography,
4951
};
5052

5153
export const SlotContext = createContext<ISlotFactoryContext>(defaultSlots);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as React from 'react';
2+
3+
import { Text } from 'react-native';
4+
5+
import { ITypographySlot } from '../../../slots/TypographySlot';
6+
7+
/**
8+
* Typography component.
9+
*
10+
* @typedef ITypographySlot
11+
* @property value - The text value to be displayed.
12+
* @property placeholder - The placeholder text to be displayed if `value` is empty.
13+
* @property typoVariant - The variant of the typography component (default: 'body1').
14+
*
15+
* @param props - The props for the Typography component.
16+
* @returns The rendered Typography component.
17+
*/
18+
export const Typography = ({
19+
value = '',
20+
placeholder = '',
21+
}: ITypographySlot) => (
22+
<Text>
23+
{value || placeholder}
24+
</Text>
25+
);
26+
27+
export default Typography;

packages/rn-declarative/src/components/One/config/createField.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import RatingField from "../fields/RatingField";
2222
import SliderField from "../fields/SliderField";
2323
import TimeField from "../fields/TimeField";
2424
import ChooseField from "../fields/ChooseField";
25+
import TypographyField from "../fields/TypographyField";
2526

2627
const fieldMap: { [key in FieldType]?: React.ComponentType<IEntity> } = Object.create(null);
2728

@@ -58,6 +59,7 @@ Object.assign(fieldMap, {
5859
[FieldType.Slider]: SliderField,
5960
[FieldType.Time]: TimeField,
6061
[FieldType.Choose]: ChooseField,
62+
[FieldType.Typography]: TypographyField,
6163
});
6264

6365
/**

0 commit comments

Comments
 (0)