Skip to content

Commit

Permalink
feat: add sex generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ZACHSTRIVES committed Aug 14, 2023
1 parent 5fb5538 commit dc43e69
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 5 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"react-redux": "^8.0.5",
"react-reflex": "^4.1.0",
"redux-persist": "^6.0.0",
"sass": "^1.63.4",
"sass": "^1.65.1",
"tailwindcss": "^3.3.2",
"tsx": "^3.12.7",
"uuidjs": "^5.0.1"
Expand Down
1 change: 1 addition & 0 deletions src/constants/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export enum DataTypeCategory {
}

export enum DataType {
SEX = "sex",
NUMBER = "number",
EMAIL = "email",
// DATE_TIME = "dateTime",
Expand Down
35 changes: 35 additions & 0 deletions src/core/generators/Sex/Sex.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from "react";
import {GenerateResult, GeneratorOptionsComponentInterface} from "@/types/generator";
import {ExportValueType} from "@/constants/enums";
import {faker} from "@faker-js/faker";

// -------------------------------------------------------------------------------------------------------------
// types
export interface SexGeneratorOptions {

}

// -------------------------------------------------------------------------------------------------------------
// default options
export const SexGeneratorDefaultOptions:SexGeneratorOptions = {
}

// -------------------------------------------------------------------------------------------------------------
// generate method
export const generate = (options: any): GenerateResult => {
const value = faker.person.sex();

return {
value: value,
stringValue: value,
type: ExportValueType.STRING
}
}

// -------------------------------------------------------------------------------------------------------------
// options component
export const SexGeneratorOptionsComponent: React.FunctionComponent<GeneratorOptionsComponentInterface> = ({...props}) => {
const {options, onOptionsChange} = props;
// TODO: implement your own options component here
return null;
}
13 changes: 13 additions & 0 deletions src/core/generators/Sex/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {Generator} from "@/types/generator";
import {DataType, DataTypeCategory} from "@/constants/enums";
import {SexGeneratorDefaultOptions, SexGeneratorOptionsComponent, generate} from "./Sex";

export const SexGenerator: Generator = {
type: DataType.SEX,
category: DataTypeCategory.PERSON,
generate: generate,
optionsComponent: SexGeneratorOptionsComponent,
defaultOptions: SexGeneratorDefaultOptions,
exampleLines: ['"male"', '"female"']
}

2 changes: 2 additions & 0 deletions src/core/generators/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {SexGenerator} from "@/core/generators/Sex";
import {BooleanGenerator} from "@/core/generators/Boolean";
import {NumberGenerator} from "@/core/generators/Number";
import {FullNameGenerator} from "@/core/generators/FullName";
Expand All @@ -6,6 +7,7 @@ import {CompanyNameGenerator} from "@/core/generators/CompanyName";
import {DataType} from "@/constants/enums";

export const generators = {
[DataType.SEX]: SexGenerator,
[DataType.BOOLEAN]: BooleanGenerator,
[DataType.NUMBER]: NumberGenerator,
[DataType.FULL_NAME]: FullNameGenerator,
Expand Down
4 changes: 4 additions & 0 deletions src/locale/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export const en = {
// -------------------------------------------------------------------------------------------------------------
// data types


// sex
"dataType.sex": "Sex",

// number
"dataType.number": "Number",
"dataType.number.kind.label": "Kind",
Expand Down
4 changes: 4 additions & 0 deletions src/locale/translations/jaJP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const jaJP = {
// -------------------------------------------------------------------------------------------------------------
// data types


// sex
"dataType.sex": "Sex",

// data type category
"dataType.category.all": "全て",
"dataType.category.basic": "基本",
Expand Down
4 changes: 4 additions & 0 deletions src/locale/translations/zhCN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export const zhCN = {
// -------------------------------------------------------------------------------------------------------------
// data types


// sex
"dataType.sex": "性别(生物学)",

// number
"dataType.number": "数字",
"dataType.number.kind.label": "种类",
Expand Down

0 comments on commit dc43e69

Please sign in to comment.