├── .eslintrc ├── .gitignore ├── LICENSE ├── README.md ├── config ├── env.js ├── jest │ ├── cssTransform.js │ └── fileTransform.js ├── material-sass-importer.js ├── paths.js ├── polyfills.js ├── webpack.config.dev.js ├── webpack.config.prod.js ├── webpack.styles.config.js └── webpackDevServer.config.js ├── package-lock.json ├── package.json ├── public ├── index.html └── manifest.json ├── scripts ├── build.js └── start.js └── src ├── App.js ├── ButtonCatalog.js ├── CardCatalog.js ├── CatalogPage.js ├── CheckboxCatalog.js ├── ChipsCatalog.js ├── ComponentCatalogPanel.js ├── ComponentImageList.js ├── ComponentPage.js ├── ComponentSidebar.js ├── DataTableCatalog.js ├── DialogCatalog.js ├── DrawerCatalog.js ├── ElevationCatalog.js ├── FabCatalog.js ├── FormField.js ├── HeaderBar.js ├── IFrameRoutes.js ├── IconButtonCatalog.js ├── ImageListCatalog.js ├── LayoutGridCatalog.js ├── LinearProgressIndicatorCatalog.js ├── ListCatalog.js ├── MenuCatalog.js ├── RadioButtonCatalog.js ├── RippleCatalog.js ├── Routes.js ├── SelectCatalog.js ├── SliderCatalog.js ├── SnackbarCatalog.js ├── SwitchCatalog.js ├── TabsCatalog.js ├── TextFieldCatalog.js ├── TopAppBarCatalog.js ├── TypographyCatalog.js ├── constants.js ├── frame ├── DrawerFramePage.js └── TopAppBarFramePage.js ├── hero ├── CodeTemplates.js ├── HeroComponent.js ├── HeroOptionsComponent.js ├── ReactTab.js ├── WebTab.js ├── options │ ├── FilterChipOption.js │ ├── RadioGroupOption.js │ ├── SelectOption.js │ └── TextFieldOption.js └── urlHelper.js ├── images ├── buttons_180px.svg ├── cards_180px.svg ├── checkbox_180px.svg ├── chips_180px.svg ├── data_table_180px.svg ├── dialog_180px.svg ├── drawer_180px.svg ├── elevation_180px.svg ├── floating_action_button_180px.svg ├── fonts_180px.svg ├── form_field_180px.svg ├── ic_code_24px.svg ├── ic_component_24px_white.svg ├── ic_drive_document_24px.svg ├── ic_material_design_24px.svg ├── ic_switch_24px.svg ├── ic_theme_24px.svg ├── icon_button_180px.svg ├── image_list_180px.svg ├── layout_grid_180px.svg ├── linear_progress_180px.svg ├── list_180px.svg ├── mdc_web_48dp.png ├── menu_180px.svg ├── photos │ ├── 2x3 │ │ ├── 1.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ ├── 5.jpg │ │ ├── 6.jpg │ │ ├── 7.jpg │ │ └── 8.jpg │ └── 3x2 │ │ ├── 1.jpg │ │ ├── 10.jpg │ │ ├── 11.jpg │ │ ├── 12.jpg │ │ ├── 13.jpg │ │ ├── 14.jpg │ │ ├── 15.jpg │ │ ├── 16.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ ├── 5.jpg │ │ ├── 6.jpg │ │ ├── 7.jpg │ │ ├── 8.jpg │ │ └── 9.jpg ├── radio_180px.svg ├── ripple_180px.svg ├── slider_180px.svg ├── snackbar_180px.svg ├── switch_180px.svg ├── tabs_180px.svg └── top_app_bar_180px.svg ├── index.js ├── registerServiceWorker.js └── styles ├── App.scss ├── ButtonCatalog.scss ├── CardCatalog.scss ├── CatalogPage.scss ├── CheckboxCatalog.scss ├── ChipsCatalog.scss ├── ComponentCatalogPanel.scss ├── ComponentPage.scss ├── ComponentView.scss ├── DataTableCatalog.scss ├── DialogCatalog.scss ├── DrawerCatalog.scss ├── DrawerFrameCatalog.scss ├── ElevationCatalog.scss ├── FabCatalog.scss ├── FormField.scss ├── HeaderBar.scss ├── HeroComponent.scss ├── IconButtonCatalog.scss ├── ImageListCatalog.scss ├── LayoutGridCatalog.scss ├── LinearProgressIndicatorCatalog.scss ├── ListCatalog.scss ├── MenuCatalog.scss ├── RadioButtonCatalog.scss ├── RippleCatalog.scss ├── SelectCatalog.scss ├── SliderCatalog.scss ├── SnackbarCatalog.scss ├── SwitchCatalog.scss ├── TabsCatalog.scss ├── TextFieldCatalog.scss ├── TopAppBarCatalog.scss ├── TopAppBarFrameCatalog.scss └── _variables.scss /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | extends: 'react-app', 3 | rules: { 4 | quotes: [2, 'single'], 5 | jsx-quotes: [2, 'prefer-single'], 6 | jsx-a11y/href-no-hash: [0], 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | /build 3 | /material-components-web-catalog 4 | .DS_Store 5 | .idea 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Material Components for the Web Catalog 2 | 3 | This is the [catalog of components](https://material-components.github.io/material-components-web-catalog/) for Material Components for the web (MDC Web). 4 | 5 | ## About 6 | 7 | [Material Components for the web (MDC Web)](https://github.com/material-components/material-components-web) help developers execute [Material Design](https://www.material.io). 8 | Developed by a core team of engineers and UX designers at Google, these components enable a reliable development workflow to build beautiful and functional web projects. 9 | 10 | ## Adding a new component 11 | 12 | Follow these steps to add a new component to the MDC Web demo catalog. 13 | 14 | 1. Add a new file to the `src` directory for the JSX (e.g. `FooCatalog.js`). It should follow this template: 15 | 16 | ```js 17 | import React, { Component } from 'react'; 18 | import ComponentCatalogPanel from './ComponentCatalogPanel.js'; 19 | import {MDCFoo} from '@material/foo/index'; 20 | 21 | import './styles/FooCatalog.scss'; 22 | 23 | const FooCatalog = () => { 24 | return ( 25 | } 27 | title='Foo' 28 | description='A short description about the Foo component.' 29 | designLink='https://material.io/guidelines/components/foo.html' 30 | docsLink='https://material.io/components/web/catalog/foo/' 31 | sourceLink='https://github.com/material-components/material-components-web/tree/master/packages/mdc-foo' 32 | demos={} 33 | /> 34 | ); 35 | } 36 | 37 | class FooHero extends Component { 38 | // Class methods for JS 39 | render() { 40 | return ( 41 | // JSX for the Foo component's hero header 42 | ); 43 | } 44 | } 45 | 46 | class FooDemos extends Component { 47 | // Class methods for JS 48 | render() { 49 | return ( 50 | // JSX for the Foo component demos 51 | ); 52 | } 53 | } 54 | 55 | export default FooCatalog; 56 | 57 | ``` 58 | 59 | > _NOTE_: If your components only require a `render` method, you can write functional components rather than classes, 60 | > e.g. `function Foo() { ... }`. In this case, `props` are passed in as an argument instead of accessed via `this`. 61 | 62 | 2. Add a new file to the `src/styles` directory for styling the demo page (e.g. `FooCatalog.scss`): 63 | 64 | ```js 65 | @import "@material/foo/mdc-foo"; 66 | 67 | // Custom styles here 68 | ``` 69 | 70 | 3. Add a SVG image associated with the component (e.g. `foo_180px.svg`) to the `src/images` directory. 71 | 72 | 4. Import the SVG and render a new list item inside the `render()` element in `ComponentImageList.js`: 73 | 74 | ```js 75 | import fooImg from './images/foo_180px.svg'; 76 | 77 | ... 78 | 79 | class ComponentImageList extends Component { 80 | ... 81 | render() { 82 | return ( 83 | ... 84 | {this.renderListItem('Foo', fooImg, 'foo')} 85 | ); 86 | } 87 | } 88 | ``` 89 | 90 | 5. Add a new entry in the `links` in the `render()` method in `ComponentSidebar.js`: 91 | 92 | ```js 93 | const links = [ 94 | ..., 95 | { 96 | content: 'Foo', 97 | url: '/foo', 98 | } 99 | ]; 100 | ``` 101 | 102 | 6. Add a `` in `ComponentPage.js`: 103 | 104 | ```js 105 | import FooCatalog from './FooCatalog'; 106 | 107 | class ComponentPage extends Component { 108 | ... 109 | renderComponentRoutes() { 110 | ... 111 | 112 | } 113 | } 114 | ``` 115 | 116 | ## Development 117 | 118 | To start a local server of the catalog, run 119 | 120 | ``` 121 | npm start 122 | ``` 123 | 124 | Then point your browser to http://localhost:3000/. 125 | 126 | ## Local Testing 127 | 128 | To run a build that can be locally tested using any HTTP server: 129 | 130 | 1. `npm run build` 131 | 2. Rename the `build` folder to `material-components-web-catalog` 132 | 3. Serve the top-level repository directory (e.g. with `live-server`) 133 | 4. Browse to http://localhost:/material-components-web-catalog/ 134 | 135 | ## Deployment 136 | 137 | To deploy the catalog to GitHub pages, run 138 | 139 | ``` 140 | npm run deploy 141 | ``` 142 | You should see it live on https://material-components.github.io/material-components-web-catalog/. 143 | -------------------------------------------------------------------------------- /config/env.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const paths = require('./paths'); 6 | 7 | // Make sure that including paths.js after env.js will read .env variables. 8 | delete require.cache[require.resolve('./paths')]; 9 | 10 | const NODE_ENV = process.env.NODE_ENV; 11 | if (!NODE_ENV) { 12 | throw new Error( 13 | 'The NODE_ENV environment variable is required but was not specified.' 14 | ); 15 | } 16 | 17 | // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use 18 | var dotenvFiles = [ 19 | `${paths.dotenv}.${NODE_ENV}.local`, 20 | `${paths.dotenv}.${NODE_ENV}`, 21 | // Don't include `.env.local` for `test` environment 22 | // since normally you expect tests to produce the same 23 | // results for everyone 24 | NODE_ENV !== 'test' && `${paths.dotenv}.local`, 25 | paths.dotenv, 26 | ].filter(Boolean); 27 | 28 | // Load environment variables from .env* files. Suppress warnings using silent 29 | // if this file is missing. dotenv will never modify any environment variables 30 | // that have already been set. Variable expansion is supported in .env files. 31 | // https://github.com/motdotla/dotenv 32 | // https://github.com/motdotla/dotenv-expand 33 | dotenvFiles.forEach(dotenvFile => { 34 | if (fs.existsSync(dotenvFile)) { 35 | require('dotenv-expand')( 36 | require('dotenv').config({ 37 | path: dotenvFile, 38 | }) 39 | ); 40 | } 41 | }); 42 | 43 | // We support resolving modules according to `NODE_PATH`. 44 | // This lets you use absolute paths in imports inside large monorepos: 45 | // https://github.com/facebookincubator/create-react-app/issues/253. 46 | // It works similar to `NODE_PATH` in Node itself: 47 | // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders 48 | // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. 49 | // Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. 50 | // https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 51 | // We also resolve them to make sure all tools using them work consistently. 52 | const appDirectory = fs.realpathSync(process.cwd()); 53 | process.env.NODE_PATH = (process.env.NODE_PATH || '') 54 | .split(path.delimiter) 55 | .filter(folder => folder && !path.isAbsolute(folder)) 56 | .map(folder => path.resolve(appDirectory, folder)) 57 | .join(path.delimiter); 58 | 59 | // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be 60 | // injected into the application via DefinePlugin in Webpack configuration. 61 | const REACT_APP = /^REACT_APP_/i; 62 | 63 | function getClientEnvironment(publicUrl) { 64 | const raw = Object.keys(process.env) 65 | .filter(key => REACT_APP.test(key)) 66 | .reduce( 67 | (env, key) => { 68 | env[key] = process.env[key]; 69 | return env; 70 | }, 71 | { 72 | // Useful for determining whether we’re running in production mode. 73 | // Most importantly, it switches React into the correct mode. 74 | NODE_ENV: process.env.NODE_ENV || 'development', 75 | // Useful for resolving the correct path to static assets in `public`. 76 | // For example, . 77 | // This should only be used as an escape hatch. Normally you would put 78 | // images into the `src` and `import` them in code to get their paths. 79 | PUBLIC_URL: publicUrl, 80 | } 81 | ); 82 | // Stringify all values so we can feed into Webpack DefinePlugin 83 | const stringified = { 84 | 'process.env': Object.keys(raw).reduce((env, key) => { 85 | env[key] = JSON.stringify(raw[key]); 86 | return env; 87 | }, {}), 88 | }; 89 | 90 | return { raw, stringified }; 91 | } 92 | 93 | module.exports = getClientEnvironment; 94 | -------------------------------------------------------------------------------- /config/jest/cssTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // This is a custom Jest transformer turning style imports into empty objects. 4 | // http://facebook.github.io/jest/docs/en/webpack.html 5 | 6 | module.exports = { 7 | process() { 8 | return 'module.exports = {};'; 9 | }, 10 | getCacheKey() { 11 | // The output is always the same. 12 | return 'cssTransform'; 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /config/jest/fileTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | 5 | // This is a custom Jest transformer turning file imports into filenames. 6 | // http://facebook.github.io/jest/docs/en/webpack.html 7 | 8 | module.exports = { 9 | process(src, filename) { 10 | return `module.exports = ${JSON.stringify(path.basename(filename))};`; 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /config/material-sass-importer.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | function tryResolve_(url, sourceFilename) { 4 | // Put require.resolve in a try/catch to avoid node-sass failing with cryptic libsass errors when the importer throws 5 | try { 6 | return require.resolve(url, {paths: [path.dirname(sourceFilename)]}); 7 | } catch (e) { 8 | return ''; 9 | } 10 | } 11 | 12 | function tryResolveScss(url, sourceFilename) { 13 | // Support omission of .scss and leading _ 14 | const normalizedUrl = url.endsWith('.scss') ? url : `${url}.scss`; 15 | return tryResolve_(normalizedUrl, sourceFilename) || 16 | tryResolve_(path.join(path.dirname(normalizedUrl), `_${path.basename(normalizedUrl)}`), sourceFilename); 17 | } 18 | 19 | function importer(url, prev) { 20 | if (url.startsWith('@material')) { 21 | const resolved = tryResolveScss(url, prev); 22 | return {file: resolved || url}; 23 | } 24 | return {file: url}; 25 | } 26 | 27 | module.exports = importer; 28 | -------------------------------------------------------------------------------- /config/paths.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const fs = require('fs'); 5 | const url = require('url'); 6 | 7 | // Make sure any symlinks in the project folder are resolved: 8 | // https://github.com/facebookincubator/create-react-app/issues/637 9 | const appDirectory = fs.realpathSync(process.cwd()); 10 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath); 11 | 12 | const {PUBLIC_URL} = process.env; 13 | 14 | function ensureSlash(path, needsSlash) { 15 | const hasSlash = path.endsWith('/'); 16 | if (hasSlash && !needsSlash) { 17 | return path.substr(path, path.length - 1); 18 | } else if (!hasSlash && needsSlash) { 19 | return `${path}/`; 20 | } else { 21 | return path; 22 | } 23 | } 24 | 25 | const getPublicUrl = appPackageJson => 26 | PUBLIC_URL || require(appPackageJson).homepage; 27 | 28 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer 29 | // "public path" at which the app is served. 30 | // Webpack needs to know it to put the right