Skip to content

Commit 699172e

Browse files
committed
Fix rendering in Safari
1 parent 0c3f1ff commit 699172e

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

examples/00 Chessboard/Tutorial App/Board.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@ import Knight from './Knight';
44
import { DragDropContext } from 'react-dnd';
55
import HTML5Backend from 'react-dnd/modules/backends/HTML5';
66

7+
// In a real app, you should use Autoprefixer
8+
let testEl;
9+
function getDisplayFlexValue() {
10+
if (typeof document === 'undefined') {
11+
return 'flex';
12+
}
13+
14+
if (!testEl) {
15+
testEl = document.createElement('div');
16+
}
17+
18+
testEl.style.display = '-webkit-flex';
19+
if (testEl.style.display === '-webkit-flex') {
20+
return '-webkit-flex';
21+
} else {
22+
return 'flex';
23+
}
24+
}
25+
726
@DragDropContext(HTML5Backend)
827
export default class Board {
928
static propTypes = {
@@ -44,7 +63,7 @@ export default class Board {
4463
<div style={{
4564
width: '100%',
4665
height: '100%',
47-
display: typeof window !== 'undefined' && window.safari ? '-webkit-flex' : 'flex', // Don't do that in a real app
66+
display: getDisplayFlexValue(),
4867
flexWrap: 'wrap',
4968
WebkitFlexWrap: 'wrap'
5069
}}>

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
"mocha": "^2.2.5",
7373
"null-loader": "^0.1.0",
7474
"postcss": "^4.0.2",
75-
"postcss-custom-properties": "3.0.1",
7675
"react": "^0.13.3",
7776
"react-hot-loader": "^1.2.3",
7877
"react-router": "~0.13.2",

scripts/cssTransformLoader.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,14 @@
22

33
var postcss = require('postcss');
44
var autoPrefixer = require('autoprefixer');
5-
var customProperties = require('postcss-custom-properties');
6-
var cssVars = require('../src/stubs/cssVar');
7-
8-
function escapeSlash(match) {
9-
return match.replace(/\//g, '_');
10-
}
11-
12-
function slashTransform(content) {
13-
return content.replace(/\.[\w\/\:\.]+(\s|\,)/g, escapeSlash);
14-
}
155

166
module.exports = function(content) {
177
if (this && this.cacheable) {
188
// Webpack specific call
199
this.cacheable();
2010
}
2111

22-
content = slashTransform(content);
2312
content = postcss()
24-
.use(customProperties({variables: cssVars.CSS_VARS}))
2513
.use(autoPrefixer())
2614
.process(content).css;
2715

site/webpack-client.config.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,16 @@ module.exports = {
3939
loaders: isDev ? ['react-hot-loader', 'babel-loader'] : ['babel-loader']
4040
},
4141
{
42-
test: /\.css$/,
42+
test: /\.less$/,
4343
loader: ExtractTextPlugin.extract(
4444
'style-loader',
4545
[
4646
'css-loader',
47-
path.join(__dirname, '../scripts/cssTransformLoader')
47+
path.join(__dirname, '../scripts/cssTransformLoader'),
48+
'less-loader'
4849
].join('!')
4950
)
5051
},
51-
{
52-
test: /\.less$/,
53-
loader: ExtractTextPlugin.extract(
54-
'style-loader',
55-
'css-loader!less-loader'
56-
)
57-
},
5852
{
5953
test: /\.png$/,
6054
loader: 'file-loader',

0 commit comments

Comments
 (0)