Skip to content
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

Fix readme casing #345

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
b3451dd
Port changes from SDK repo
Aug 30, 2016
f6d9c7c
Fix module resolve error with hot reloading
Aug 30, 2016
b774caa
Readme update
Aug 30, 2016
ecce993
Allow for npm link development
Aug 30, 2016
b9f5271
Nuke a bunch of styles
Aug 30, 2016
f1e0aaa
Changes
Sep 21, 2016
fc9749d
Nuke tags
Sep 21, 2016
1535d45
Pin webpack dep to 1.x
zacharyhalvorson Sep 21, 2016
91efe19
Fix lookup for design readme .md files
Sep 22, 2016
4c9e8f9
search bar styling
zacharyhalvorson Sep 22, 2016
d1ba280
Added in the components header
zacharyhalvorson Sep 22, 2016
3aa21e7
Fixed the appear to the top
zacharyhalvorson Sep 22, 2016
aefd759
Removed the styleguidist footer
zacharyhalvorson Sep 22, 2016
016983c
removed other footer
zacharyhalvorson Sep 22, 2016
443f927
Removed extra main tag
zacharyhalvorson Sep 22, 2016
4d327cc
little padding on bottom of list
zacharyhalvorson Sep 23, 2016
9299cd8
add in the detail page app bar
zacharyhalvorson Sep 23, 2016
6eb47f3
new close icon
zacharyhalvorson Sep 23, 2016
0117fac
Fix up app bar DOM position in detail mode
Sep 23, 2016
31b8764
Fix background color in detail mode
Sep 23, 2016
5724786
Hook up keyboard shorcut for search bar
Sep 23, 2016
1f896b5
multi-column layout on desktop
zacharyhalvorson Sep 26, 2016
8a4a6f9
Fix detail-page top padding
Sep 26, 2016
c19b5b1
Semicolons
Sep 26, 2016
be377c5
Merge remote-tracking branch 'sapegin/master' into ui-dev
Sep 26, 2016
61fcd89
Update Readme.md
Sep 28, 2016
c894ad5
Remove styling from styleguidist for headings
zacharyhalvorson Sep 28, 2016
e7d64e0
Remove slightly confusing console.log
Sep 28, 2016
7c354d8
Move code description above propList
Sep 28, 2016
1fdd39d
Fix f to search in Safari
Sep 28, 2016
7e1e498
Import components without JSX
Sep 28, 2016
49e24b3
Refactor design markdown import
Sep 28, 2016
6002b60
Single column layout
Sep 28, 2016
581c4f2
Scroll to top on component render
Sep 28, 2016
526e0ad
Add "Close" icon, SVG and loader to styleguidist
jeffkamo Sep 29, 2016
3f4cf44
Insert classes for markdown code css
Sep 29, 2016
bd4c3a6
clean a bit of component template's namings
jeffkamo Sep 29, 2016
5ccf454
Add identifier classnames
jeffkamo Sep 29, 2016
c5549cd
Fix render header functions and rename to make sense
jeffkamo Sep 29, 2016
c0d1cdb
Modify component list header classes
zacharyhalvorson Sep 29, 2016
3548c48
reconfigure the spacing on the list page
zacharyhalvorson Sep 29, 2016
7a4753f
tweaks to search bar styling
zacharyhalvorson Sep 29, 2016
5e5196c
Add escape keypress shortcut
zacharyhalvorson Sep 30, 2016
7f250bc
add some gd hover styles already
zacharyhalvorson Oct 4, 2016
9899579
Display sketch ui kit slices
Oct 4, 2016
615e5e2
Add hasSlice bool for whether slice.png exists
Oct 5, 2016
965c8ff
Add container class
jeffkamo Oct 6, 2016
da3e142
hover effects
zacharyhalvorson Oct 6, 2016
08f3ba3
spacing tweak
zacharyhalvorson Oct 6, 2016
8e6062d
Support for prod/dev build origins
Oct 12, 2016
2c5b625
updating code props table css
henryh15 Nov 1, 2016
e7a793c
fixing className declaration
henryh15 Nov 1, 2016
9f70ab2
css formatting
henryh15 Nov 1, 2016
d422afb
css formatting
henryh15 Nov 1, 2016
7be96d8
css test
henryh15 Nov 1, 2016
102d7fd
css tweaks
henryh15 Nov 1, 2016
857f973
css tweaks
henryh15 Nov 1, 2016
8666767
css tweaks
henryh15 Nov 1, 2016
8006f15
hiding second and third columns in prop table
henryh15 Nov 1, 2016
6a50772
hiding 2nd/3rd column in table body
henryh15 Nov 1, 2016
0513515
typo on styles
henryh15 Nov 1, 2016
3d607ee
Merge pull request #1 from mobify/ui-dev
Nov 2, 2016
7512d85
Merge tag 'v4.1.0' into merge-4.1.0
Nov 3, 2016
05130df
Fix CSS compilation error
Nov 3, 2016
041952f
Fix input focus
Nov 3, 2016
a41e670
Revert change to webpack requirement
Nov 3, 2016
3017c69
Prevent explosions for custom “Design” components
Nov 3, 2016
e896019
Properly hide code section if not present
Nov 3, 2016
2b1ad1a
Merge pull request #3 from mobify/merge-4.1.0
Nov 4, 2016
a4ce14b
Fix props table className
Nov 9, 2016
e7b294c
Merge pull request #4 from mobify/fix-props-table
Nov 9, 2016
50596ea
Change 'Readme.md' to 'README.md' for example files
Mar 6, 2017
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
7 changes: 7 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Mobify Fork

* Clone this repo and check out #ui-dev branch
* Run `npm link`
* Inside SDK repo: `npm link react-styleguidist && npm run docs:dev`
* Make any necessary changes to react-styleguidist

# React Styleguidist

[![Build Status](https://travis-ci.org/sapegin/react-styleguidist.svg)](https://travis-ci.org/sapegin/react-styleguidist) [![Dependency Status](https://david-dm.org/sapegin/react-styleguidist.svg)](https://david-dm.org/sapegin/react-styleguidist) [![npm](https://img.shields.io/npm/v/react-styleguidist.svg)](https://www.npmjs.com/package/react-styleguidist)
Expand Down
44 changes: 5 additions & 39 deletions bin/styleguidist.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,11 @@

const minimist = require('minimist');
const chalk = require('chalk');
const getConfig = require('../scripts/config');
const consts = require('../scripts/consts');
const StyleguidistError = require('../scripts/utils/error');

const argv = minimist(process.argv.slice(2));

let config;
try {
config = getConfig(argv);
}
catch (err) {
if (err instanceof StyleguidistError) {
console.error(chalk.bold.red(err.message));
console.log();
console.log('Learn how to configure your style guide:');
console.log(chalk.underline(consts.DOCS_CONFIG));
process.exit(1);
}
else {
throw err;
}
}
const getConfig = require('../scripts/config');
const config = getConfig(argv);

switch (argv._[0]) {
case 'build':
Expand All @@ -50,37 +33,20 @@ function commandBuild() {
process.exit(1);
}
else {
console.log('Style guide published to:');
console.log(chalk.underline(config.styleguideDir));
console.log('Style guide published to', chalk.underline(config.styleguideDir));
}
});
}

function commandServer() {
process.on('uncaughtException', err => {
if (err.code === 'EADDRINUSE') {
console.error(chalk.bold.red(
`You have another server running at port ${config.serverPort} somewhere, shut it down first`
));
console.log();
console.log('You can change the port using the `serverPort` option in your style guide config:');
console.log(chalk.underline(consts.DOCS_CONFIG));
process.exit(1);
}
else {
throw err;
}
});

const server = require('../scripts/server');
server(config, err => {
if (err) {
console.log(err);
}
else {
console.log('Style guide server started at:');
console.log(chalk.underline('http://' + config.serverHost + ':' + config.serverPort));
console.log();
// console.log('Listening at', chalk.underline('http://' + config.serverHost + ':' + config.serverPort));
console.log('React Styleguidist is building...');
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const StyleGuideRenderer = ({ title, components, toc, sidebar }) => (
<div className={s.wrapper}>
<div className={s.components}>
{components}
<footer className={s.footer}>
Generated with <a className={s.link} href="https://github.com/sapegin/react-styleguidist">React Styleguidist</a>
</footer>
</div>
{sidebar &&
<div className={s.sidebar}>{toc}</div>
Expand Down
6 changes: 6 additions & 0 deletions loaders/examples.loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const EVAL_PLACEHOLDER_REGEXP = new RegExp(escapeRegExp(JSON.stringify(EVAL_PLAC
const COMPONENT_PLACEHOLDER = '__COMPONENT__';
const COMPONENT_PLACEHOLDER_REGEXP = new RegExp(escapeRegExp(COMPONENT_PLACEHOLDER), 'g');

const IMAGE_PLACEHOLDER = '__IMG_ORIGIN__';
const IMAGE_PLACEHOLDER_REGEXP = new RegExp(escapeRegExp(IMAGE_PLACEHOLDER), 'g');

function examplesLoader(source) {
if (this.cacheable) {
this.cacheable();
Expand All @@ -23,6 +26,9 @@ function examplesLoader(source) {
const componentName = query.componentName || COMPONENT_PLACEHOLDER;
source = source.replace(COMPONENT_PLACEHOLDER_REGEXP, componentName);

// Replace __IMAGE_ORIGIN__ with the passed-in image path
source = source.replace(IMAGE_PLACEHOLDER_REGEXP, query.imagePath)

// Load examples
let examples = chunkify(source);

Expand Down
50 changes: 40 additions & 10 deletions loaders/styleguide.loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,22 @@ const utils = require('./utils/js');
const requireIt = utils.requireIt;
const toCode = utils.toCode;

const DESIGN_CONTENT_NAME = 'DESIGN_README'
const SLICE_NAME = 'slice'

/* eslint-disable no-console */

function hasSlice(filepath, config) {
const sliceFileName = config.getExampleFilename(filepath, `assets/${SLICE_NAME}.png`)
const filename = path.parse(filepath).name;

if (filename === 'index' || filename === DESIGN_CONTENT_NAME) {
return fs.existsSync(sliceFileName);
} else {
return path.basename(path.dirname(filepath)) === filename && fs.existsSync(sliceFileName)
}
}

/**
* Return JS code as a string for a component with all required for style guide information.
*
Expand All @@ -20,17 +34,33 @@ const toCode = utils.toCode;
*/
function processComponent(filepath, config) {
const nameFallback = getNameFallback(filepath);
const examplesFile = config.getExampleFilename(filepath);
const componentPath = path.relative(config.configDir, filepath);
const designMarkdownFileName = config.getExampleFilename(filepath, `${DESIGN_CONTENT_NAME}.md`)
const sliceFileName = config.getExampleFilename(filepath, 'slice.png')

return toCode({
// You need to stringify these - otherwise you'll get a compilation error!
const code = {
imagePath: JSON.stringify(config.imagePath),
hasSlice: hasSlice(filepath, config),
filepath: JSON.stringify(filepath),
nameFallback: JSON.stringify(nameFallback),
pathLine: JSON.stringify(config.getComponentPathLine(componentPath)),
module: requireIt(filepath),
props: requireIt('!!props!' + filepath),
examples: getExamples(examplesFile, nameFallback, config.defaultExample),
});
designMarkdown: getExamples(designMarkdownFileName, nameFallback, config.defaultExample, config.imagePath)
};

if (path.basename(filepath) !== `${DESIGN_CONTENT_NAME}.md`) {
const examplesFileName = config.getExampleFilename(filepath);

code.examples = getExamples(examplesFileName, nameFallback, config.defaultExample, config.imagePath);
code.module = requireIt(filepath);
code.props = requireIt('!!props!' + filepath);
} else {
// Later on in the application, we'll deconstruct this property and accessing
// an undefined property will explode - so let's give it an empty object
code.props = JSON.stringify({})
}

return toCode(code);
}

/**
Expand All @@ -41,7 +71,7 @@ function processComponent(filepath, config) {
*/
function getNameFallback(filepath) {
const filename = path.parse(filepath).name;
return filename === 'index' ? path.basename(path.dirname(filepath)) : filename;
return (filename === 'index' || filename === DESIGN_CONTENT_NAME) ? path.basename(path.dirname(filepath)) : filename;
}

/**
Expand All @@ -52,13 +82,13 @@ function getNameFallback(filepath) {
* @param {string} defaultExample
* @returns {string}
*/
function getExamples(examplesFile, nameFallback, defaultExample) {
function getExamples(examplesFile, nameFallback, defaultExample, imagePath) {
if (fs.existsSync(examplesFile)) {
return requireIt('examples!' + examplesFile);
return requireIt('examples?imagePath=' + imagePath + '!' + examplesFile);
}

if (defaultExample) {
return requireIt('examples?componentName=' + nameFallback + '!' + defaultExample);
return requireIt('examples?imagePath=' + imagePath + '&componentName=' + nameFallback + '!' + defaultExample);
}

return null;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"remark-parse": "~2.0.2",
"semver-utils": "1.1.1",
"style-loader": "0.13.1",
"svg-react-loader": "0.3.7",
"unified": "~5.1.0",
"unist-util-visit": "~1.1.0",
"webpack-dev-middleware": "1.8.4",
Expand Down
14 changes: 10 additions & 4 deletions scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ const DEFAULT_CONFIG = {
serverPort: 3000,
highlightTheme: 'base16-light',
verbose: false,
getExampleFilename: componentpath => path.join(path.dirname(componentpath), 'Readme.md'),
getExampleFilename: (componentpath, fileName) => {
// Careful: Mobify decision to use README.md. On some systems (Linux) the filesystem
// is case sensitive and so the files in git _must_ match this casing.
fileName = fileName ? fileName : 'README.md';

return path.join(path.dirname(componentpath), fileName);
},
getComponentPathLine: componentpath => componentpath,
updateWebpackConfig: null,
};
Expand Down Expand Up @@ -120,8 +126,8 @@ function getConfig(options) {
function findConfig(file) {
if (file) {
// Custom config location

const configFilepath = file[0] === '/' ? file : path.join(process.cwd(), file);

if (!fs.existsSync(configFilepath)) {
throw new StyleguidistError('Styleguidist config not found: ' + configFilepath + '.');
}
Expand All @@ -130,10 +136,10 @@ function findConfig(file) {
}

// Search config file in all parent directories

let configDir;

try {
configDir = findup.sync(__dirname, CONFIG_FILENAME);
configDir = findup.sync(process.cwd(), CONFIG_FILENAME);
}
catch (exception) {
throw new StyleguidistError('Styleguidist config not found: ' + CONFIG_FILENAME + '.');
Expand Down
23 changes: 21 additions & 2 deletions scripts/make-webpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,24 @@ module.exports = function(config, env) {

const isProd = env === 'production';

// Allow for users to provide production or dev-based image origins for embedded
// assets in markdown files
let assetBuildOrigin = ''

if (config.assetBuildOrigin) {
assetBuildOrigin = isProd ? config.assetBuildOrigin.prod : config.assetBuildOrigin.dev
}

if (config.imagePath) {
config.imagePath = assetBuildOrigin + '/' + path.join(config.imagePath, '/');
} else {
config.imagePath = ''
}

let webpackConfig = {
output: {
path: config.styleguideDir,
filename: 'build/bundle.js',
filename: 'styleguidist.js',
},
resolve: {
alias: {
Expand Down Expand Up @@ -96,6 +110,11 @@ module.exports = function(config, env) {
include: sourceDir,
loader: 'style!css?modules&importLoaders=1&localIdentName=ReactStyleguidist-[name]__[local]',
},
{
test: /\.svg$/,
include: sourceDir,
loader: 'babel!svg-react',
},
],
noParse: /babel-standalone/,
},
Expand Down Expand Up @@ -189,7 +208,7 @@ module.exports = function(config, env) {
else {
webpackConfig = merge(webpackConfig, {
entry: [
'webpack-hot-middleware/client',
require.resolve('webpack-hot-middleware/client'),
entryScript,
],
cache: true,
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import StyleGuide from 'rsg-components/StyleGuide';

import 'highlight.js/styles/tomorrow.css';
import './styles.css';

// Make libraries available in examples
global.React = React;
Expand Down
Loading