Skip to content

Commit

Permalink
Merge pull request #161 from Drawbotics/feature/typescript-mdx
Browse files Browse the repository at this point in the history
Feature/typescript mdx
  • Loading branch information
nicmosc authored Nov 24, 2020
2 parents 70e1487 + 565fe96 commit 34f92d3
Show file tree
Hide file tree
Showing 14 changed files with 1,041 additions and 341 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
extends: ['eslint:recommended', 'plugin:jest/recommended'],
parserOptions: {
sourceType: 'module',
project: 'packages/react-drylus/tsconfig.json',
project: ['packages/react-drylus/tsconfig.json', 'packages/styleguide/tsconfig.json'],
},
env: {
node: true,
Expand Down
1,184 changes: 860 additions & 324 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@
"@drawbotics/s3sync": "^0.1.1",
"@emotion/core": "^10.0.21",
"@hot-loader/react-dom": "^16.8.6",
"@mdx-js/loader": "^1.0.0-rc.4",
"@mdx-js/react": "^1.0.0-rc.5",
"@mdx-js/loader": "^1.6.21",
"@mdx-js/react": "^1.6.21",
"@types/animejs": "^3.1.0",
"@types/lodash": "^4.14.149",
"@types/mapbox-gl": "^1.8.1",
"@types/react": "^16.9.23",
"@types/react-dom": "^16.9.5",
"@types/react-router-dom": "^5.1.6",
"@types/react-test-renderer": "^16.9.2",
"@types/uuid": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^2.22.0",
Expand Down Expand Up @@ -126,6 +127,8 @@
"rimraf": "^2.6.2",
"style-loader": "^0.23.1",
"ts-jest": "^24.3.0",
"ts-loader": "^8.0.11",
"tsconfig-paths-webpack-plugin": "^3.3.0",
"typedoc": "^0.16.11",
"typescript": "^3.8.3",
"webfont": "^8.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import '@drawbotics/vanilla-drylus/dist/drylus.css';

import { DrylusProvider, Layout, Page, Position } from '@drawbotics/react-drylus';
import { useScreenSize } from '@drawbotics/use-screen-size';
// @ts-ignore
import drylus from '@drawbotics/vanilla-drylus/dist/drylus.js';
import { css } from 'emotion';
import React from 'react';
import { hot } from 'react-hot-loader';
import { BrowserRouter } from 'react-router-dom';

import MobileSidebar from './components/MobileSidebar';
import Sidebar from './components/Sidebar';
import Root from './routes/Root';
import MobileSidebar from './components/MobileSidebar.jsx';
import Sidebar from './components/Sidebar.jsx';
import { Root } from './routes/Root';

window._drylus = drylus;

Expand All @@ -24,7 +25,6 @@ const styles = {

const App = () => {
const { screenSize, ScreenSizes } = useScreenSize();
console.log('App running');
return (
<div className={styles.app}>
<BrowserRouter basename="drylus">
Expand All @@ -44,7 +44,7 @@ const App = () => {
<div
style={{
height: '100%',
width: screenSize <= ScreenSizes.L ? '100vw' : null,
width: screenSize <= ScreenSizes.L ? '100vw' : undefined,
}}>
<Root />
</div>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { Route, Switch } from 'react-router-dom';

import CodingGuidelines from './CodingGuidelines';
import ComponentKit from './ComponentKit';
import DesignGuidelines from './DesignGuidelines';
import Intro from './Intro';
import CodingGuidelines from './CodingGuidelines.jsx';
import ComponentKit from './ComponentKit.jsx';
import DesignGuidelines from './DesignGuidelines.jsx';
import Intro from './Intro.jsx';

const Root = () => {
export const Root = () => {
return (
<Switch>
<Route path="/component-kit" component={ComponentKit} />
Expand All @@ -16,5 +16,3 @@ const Root = () => {
</Switch>
);
};

export default Root;
7 changes: 7 additions & 0 deletions packages/styleguide/app/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare global {
interface Window {
_drylus: any;
}
}

export {};
1 change: 1 addition & 0 deletions packages/styleguide/app/types/jsx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '*.jsx';
37 changes: 37 additions & 0 deletions packages/styleguide/app/types/mdx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
declare module '@mdx-js/react' {
import * as React from 'react';
type ComponentType =
| 'a'
| 'blockquote'
| 'code'
| 'delete'
| 'em'
| 'h1'
| 'h2'
| 'h3'
| 'h4'
| 'h5'
| 'h6'
| 'hr'
| 'img'
| 'inlineCode'
| 'li'
| 'ol'
| 'p'
| 'pre'
| 'strong'
| 'sup'
| 'table'
| 'td'
| 'thematicBreak'
| 'tr'
| 'ul';
export type Components = {
[key in ComponentType]?: React.ComponentType<any>;
};
export interface MDXProviderProps {
children: React.ReactNode;
components: Components;
}
export class MDXProvider extends React.Component<MDXProviderProps> {}
}
1 change: 1 addition & 0 deletions packages/styleguide/app/types/use-screen-size.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@drawbotics/use-screen-size';
49 changes: 49 additions & 0 deletions packages/styleguide/package-lock.json

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

4 changes: 4 additions & 0 deletions packages/styleguide/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "./dist"],
}
30 changes: 30 additions & 0 deletions packages/styleguide/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"jsx": "preserve",
"moduleResolution": "node",
"allowJs": false,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "ES2018",
"sourceMap": false,
"outDir": "./dist",
"incremental": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"strict": true,
"baseUrl": "./",
"declaration": true,
"declarationMap": true,
"inlineSourceMap": true,
"inlineSources": true,
"resolveJsonModule": true,
"paths": {
"~/*": ["./app/*"]
}
},
"include": [
"./app/**/*.tsx",
"./app/**/*.ts"
]
}
38 changes: 36 additions & 2 deletions packages/styleguide/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const { checkEnv } = require('@drawbotics/check-env');
Expand Down Expand Up @@ -73,7 +74,7 @@ module.exports = {
mode: process.env.NODE_ENV,
devtool: isProduction ? 'source-map' : 'cheap-module-eval-source-map',
stats: 'none',
entry: './app/index.js',
entry: './app/index.tsx',
resolve: {
modules: [
path.resolve(__dirname, './app'),
Expand All @@ -83,7 +84,8 @@ module.exports = {
'~': path.resolve(__dirname, './app'),
'react-dom': '@hot-loader/react-dom',
},
extensions: [ '.js', '.jsx', '.css', '.mdx' ],
extensions: [ '.js', '.jsx', '.css', '.mdx', '.ts', '.tsx' ],
plugins: [new TsconfigPathsPlugin()],
},
output: {
path: path.resolve(__dirname, './dist'),
Expand All @@ -97,6 +99,28 @@ module.exports = {
plugins: isProduction ? prodPlugins : devPlugins,
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
rootMode: 'upward',
},
},
{
loader: 'ts-loader',
options: {
onlyCompileBundledFiles: true,
compilerOptions: {
noUnusedLocals: isProduction,
noUnusedParameters: isProduction,
},
},
},
],
},
{
test: /\.jsx?$/,
use: [{
Expand All @@ -123,6 +147,16 @@ module.exports = {
rootMode: 'upward',
},
},
// {
// loader: 'ts-loader',
// options: {
// onlyCompileBundledFiles: true,
// compilerOptions: {
// noUnusedLocals: isProduction,
// noUnusedParameters: isProduction,
// },
// },
// },
{
loader: '@mdx-js/loader',
options: {
Expand Down

0 comments on commit 34f92d3

Please sign in to comment.