-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from zendesk/gianluca/typescript
Added TypeScript support
- Loading branch information
Showing
15 changed files
with
637 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
{ | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:prettier/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:import/recommended", | ||
"plugin:react/recommended" | ||
"plugin:import/typescript", | ||
"plugin:react/recommended", | ||
"plugin:react/jsx-runtime", | ||
"plugin:prettier/recommended" | ||
], | ||
"env": { | ||
"browser": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2015, | ||
"sourceType": "module" | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"root": true, | ||
"settings": { | ||
"import/resolver": { | ||
"typescript": true, | ||
"node": true | ||
}, | ||
"react": { | ||
"version": "detect" | ||
} | ||
}, | ||
"ignorePatterns": ["assets/**"], | ||
"rules": { | ||
"@typescript-eslint/consistent-type-imports": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { TicketForm } from "./data-types/TicketForm"; | ||
import { TicketFormField } from "./ticket-form-field/TicketFormField"; | ||
|
||
export interface NewRequestFormProps { | ||
ticketForms: TicketForm[]; | ||
} | ||
|
||
export function NewRequestForm({ ticketForms }: NewRequestFormProps) { | ||
return ( | ||
<form> | ||
<TicketFormField ticketForms={ticketForms} /> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface TicketForm { | ||
id: string; | ||
url: string; | ||
name: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { renderNewRequestForm } from "./renderNewRequestForm"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { render } from "react-dom"; | ||
import { ComponentProviders } from "../shared"; | ||
import type { NewRequestFormProps } from "./NewRequestForm"; | ||
import { NewRequestForm } from "./NewRequestForm"; | ||
|
||
export function renderNewRequestForm( | ||
props: NewRequestFormProps, | ||
container: HTMLElement | ||
) { | ||
render( | ||
<ComponentProviders> | ||
<NewRequestForm {...props} /> | ||
</ComponentProviders>, | ||
container | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/modules/new-request-form/ticket-form-field/TicketFormField.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { IComboboxProps } from "@zendeskgarden/react-dropdowns.next"; | ||
import { | ||
Combobox, | ||
Field, | ||
Label, | ||
Option, | ||
} from "@zendeskgarden/react-dropdowns.next"; | ||
import type { TicketForm } from "../data-types/TicketForm"; | ||
|
||
interface TicketFormFieldProps { | ||
ticketForms: TicketForm[]; | ||
} | ||
|
||
export function TicketFormField({ ticketForms }: TicketFormFieldProps) { | ||
const handleChange: IComboboxProps["onChange"] = ({ selectionValue }) => { | ||
if (selectionValue && typeof selectionValue === "string") { | ||
window.location.href = selectionValue; | ||
} | ||
}; | ||
|
||
return ( | ||
<Field> | ||
<Label>Please choose your issue below</Label> | ||
<Combobox isEditable={false} onChange={handleChange}> | ||
{ticketForms.map(({ id, url, name }) => ( | ||
<Option key={id} value={url} label={name}> | ||
{name} | ||
</Option> | ||
))} | ||
</Combobox> | ||
</Field> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { IGardenTheme } from "@zendeskgarden/react-theming"; | ||
import { ThemeProvider, DEFAULT_THEME } from "@zendeskgarden/react-theming"; | ||
import type { ReactNode } from "react"; | ||
|
||
let theme = DEFAULT_THEME; | ||
|
||
export function setupGardenTheme( | ||
callback: (defaultTheme: IGardenTheme) => IGardenTheme | ||
) { | ||
theme = callback(DEFAULT_THEME); | ||
} | ||
|
||
export function ComponentProviders({ children }: { children: ReactNode }) { | ||
return <ThemeProvider theme={theme}>{children}</ThemeProvider>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"lib": ["DOM", "DOM.Iterable", "ESNext"], | ||
"allowJs": false, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noImplicitReturns": true, | ||
"noUncheckedIndexedAccess": true, | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx" | ||
}, | ||
"include": ["src/modules"] | ||
} |
Oops, something went wrong.