Skip to content

[docs] Transpile demo .ts files #22388

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

Merged
merged 5 commits into from
Aug 30, 2020
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
2 changes: 0 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"@types/react-virtualized": "^9.21.4",
"@types/react-window": "^1.7.0",
"@types/styled-components": "5.1.2",
"@types/validator": "^13.1.0",
"accept-language": "^3.0.18",
"address": "^1.0.3",
"ast-types": "^0.13.2",
Expand Down Expand Up @@ -109,7 +108,6 @@
"redux-logger": "^3.0.6",
"rimraf": "^3.0.0",
"styled-components": "^5.0.0",
"validator": "^13.1.1",
"webfontloader": "^1.6.28",
"webpack": "^4.41.0",
"webpack-bundle-analyzer": "^3.5.1"
Expand Down
5 changes: 3 additions & 2 deletions docs/scripts/formattedTSDemos.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ async function getFiles(root) {
files.push(...(await getFiles(filePath)));
} else if (
stat.isFile() &&
filePath.endsWith('.tsx') &&
/\.tsx?$/.test(filePath) &&
!filePath.endsWith('.d.ts') &&
!ignoreList.some((ignorePath) => filePath.endsWith(path.normalize(ignorePath)))
) {
files.push(filePath);
Expand All @@ -61,7 +62,7 @@ const TranspileResult = {
};

async function transpileFile(tsxPath, program, ignoreCache = false) {
const jsPath = tsxPath.replace('.tsx', '.js');
const jsPath = tsxPath.replace(/\.tsx?$/, '.js');
try {
if (!ignoreCache && (await fse.exists(jsPath))) {
const [jsStat, tsxStat] = await Promise.all([fse.stat(jsPath), fse.stat(tsxPath)]);
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/premium-themes/onepirate/ForgotPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function ForgotPassword() {
if (!errors.email) {
const emailError = email(values.email);
if (emailError) {
errors.email = email(values.email);
errors.email = emailError;
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/premium-themes/onepirate/ForgotPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function ForgotPassword() {
if (!errors.email) {
const emailError = email(values.email);
if (emailError) {
errors.email = email(values.email);
errors.email = emailError;
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/premium-themes/onepirate/SignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function SignIn() {
if (!errors.email) {
const emailError = email(values.email);
if (emailError) {
errors.email = email(values.email);
errors.email = emailError;
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/premium-themes/onepirate/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function SignIn() {
if (!errors.email) {
const emailError = email(values.email);
if (emailError) {
errors.email = email(values.email);
errors.email = emailError;
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/premium-themes/onepirate/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function SignUp() {
if (!errors.email) {
const emailError = email(values.email);
if (emailError) {
errors.email = email(values.email);
errors.email = emailError;
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/premium-themes/onepirate/SignUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function SignUp() {
if (!errors.email) {
const emailError = email(values.email);
if (emailError) {
errors.email = email(values.email);
errors.email = emailError;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import MuiAppBar from '@material-ui/core/AppBar';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { withStyles, Theme, WithStyles } from '@material-ui/core/styles';
import MuiAppBar, { AppBarProps } from '@material-ui/core/AppBar';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { withStyles } from '@material-ui/core/styles';
import MuiButton from '@material-ui/core/Button';
import React from 'react';
import * as React from 'react';

const styles = (theme) => ({
root: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
createStyles,
} from '@material-ui/core/styles';
import MuiButton, { ButtonProps } from '@material-ui/core/Button';
import React from 'react';
import * as React from 'react';

const styles = (theme: Theme) =>
createStyles({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import ReactMarkdown from 'markdown-to-jsx';
import { withStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import ReactMarkdown from 'markdown-to-jsx';
import {
Theme,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import MuiPaper from '@material-ui/core/Paper';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import clsx from 'clsx';
import MuiPaper, { PaperProps } from '@material-ui/core/Paper';
import { withStyles, Theme, WithStyles } from '@material-ui/core/styles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import MuiSnackbar from '@material-ui/core/Snackbar';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import {
withStyles,
WithStyles,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { withStyles } from '@material-ui/core/styles';
Expand Down Expand Up @@ -81,14 +81,9 @@ function TextField(props) {
...InputPropsOther
} = InputProps;

const disableUnderline = {
disableUnderline: true,
};

return (
<MuiTextField
InputProps={{
...disableUnderline,
classes: {
root: classes.root,
input: clsx(
Expand All @@ -102,6 +97,7 @@ function TextField(props) {
disabled: classes.disabled,
...InputPropsClassesOther,
},
disableUnderline: true,
...InputPropsOther,
}}
InputLabelProps={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';
import * as React from 'react';
import clsx from 'clsx';
import { withStyles, WithStyles, createStyles } from '@material-ui/core/styles';
import MuiTextField, { TextFieldProps } from '@material-ui/core/TextField';
import MuiTextField, {
FilledTextFieldProps,
StandardTextFieldProps,
} from '@material-ui/core/TextField';

const inputSyleMapping = {
small: 'inputSizeSmall',
Expand Down Expand Up @@ -65,7 +68,8 @@ const styles = (theme: any) =>
},
});

export interface OnePirateTextFieldProps extends Omit<TextFieldProps, 'size'> {
export interface OnePirateTextFieldProps
extends Omit<FilledTextFieldProps | StandardTextFieldProps, 'size'> {
noBorder?: boolean;
size?: 'small' | 'medium' | 'large' | 'xlarge';
}
Expand All @@ -86,14 +90,9 @@ function TextField(props: OnePirateTextFieldProps & WithStyles<typeof styles>) {
...InputPropsOther
} = InputProps;

const disableUnderline = {
disableUnderline: true,
};

return (
<MuiTextField
InputProps={{
...disableUnderline,
classes: {
root: classes.root,
input: clsx(
Expand All @@ -107,6 +106,7 @@ function TextField(props: OnePirateTextFieldProps & WithStyles<typeof styles>) {
disabled: classes.disabled,
...InputPropsClassesOther,
},
disableUnderline: true,
...InputPropsOther,
}}
InputLabelProps={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import MuiTypography from '@material-ui/core/Typography';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import {
withStyles,
WithStyles,
Expand Down
16 changes: 10 additions & 6 deletions docs/src/pages/premium-themes/onepirate/modules/form/validation.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import validator from 'validator';
// Simplified method of validator/lib/isEmail
function isEmail(string: string) {
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(string);
}

export function email(value: string) {
return value && !validator.isEmail(value.trim()) ? 'Invalid email' : null;
return value && !isEmail(value.trim()) ? 'Invalid email' : null;
}

function isDirty(value: string) {
return value;
function isDirty(value: string | number) {
return value || value === 0;
}

export function required(
requiredFields: string[],
values: { [index: string]: string },
): { [index: string]: string | null } {
values: Record<string, string>,
): Record<string, string> {
return requiredFields.reduce(
(fields, field) => ({
...fields,
Expand Down
7 changes: 3 additions & 4 deletions docs/src/pages/premium-themes/onepirate/modules/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ const rawTheme = createMuiTheme({
dark: '#ffb25e',
},
error: {
xLight: red[50],
light: red[50],
main: red[500],
dark: red[700],
},
success: {
xLight: green[50],
light: green[50],
main: green[500],
dark: green[700],
},
Expand All @@ -34,14 +34,13 @@ const rawTheme = createMuiTheme({
fontWeightLight: 300, // Work Sans
fontWeightRegular: 400, // Work Sans
fontWeightMedium: 700, // Roboto Condensed
fontFamilySecondary: "'Roboto Condensed', sans-serif",
},
});

const fontHeader = {
color: rawTheme.palette.text.primary,
fontWeight: rawTheme.typography.fontWeightMedium,
fontFamily: rawTheme.typography.fontFamilySecondary,
fontFamily: "'Roboto Condensed', sans-serif",
textTransform: 'uppercase',
};

Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2917,11 +2917,6 @@
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.0.tgz#215c231dff736d5ba92410e6d602050cce7e273f"
integrity sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==

"@types/validator@^13.1.0":
version "13.1.0"
resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.1.0.tgz#3d776127dbce7dd31fc06f86d3428b072e631eba"
integrity sha512-gHUHI6pJaANIO2r6WcbT7+WMgbL9GZooR4tWpuBOETpDIqFNxwaJluE+6rj6VGYe8k6OkfhbHz2Fkm8kl06Igw==

"@types/yargs-parser@*":
version "15.0.0"
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-15.0.0.tgz#cb3f9f741869e20cce330ffbeb9271590483882d"
Expand Down Expand Up @@ -16465,11 +16460,6 @@ validate-npm-package-name@^3.0.0:
dependencies:
builtins "^1.0.3"

validator@^13.1.1:
version "13.1.1"
resolved "https://registry.yarnpkg.com/validator/-/validator-13.1.1.tgz#f8811368473d2173a9d8611572b58c5783f223bf"
integrity sha512-8GfPiwzzRoWTg7OV1zva1KvrSemuMkv07MA9TTl91hfhe+wKrsrgVN4H2QSFd/U/FhiU3iWPYVgvbsOGwhyFWw==

value-equal@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.4.0.tgz#c5bdd2f54ee093c04839d71ce2e4758a6890abc7"
Expand Down