Use Material UI; improve Preferences Page

New principles for our UI:

- Components should use inline styles whenever possible
- Let's shrink the size of main.css to < 100 lines over time so it just
contains typography and basic styles
- Always require just the individual component that is needed from
Material UI so that the whole library doesn't get loaded (important for
startup perf)
This commit is contained in:
Feross Aboukhadijeh
2016-08-22 17:53:29 -07:00
parent b4976d27f2
commit 1a01d7ed92
14 changed files with 234 additions and 383 deletions

View File

@@ -1,76 +0,0 @@
.Button {
-webkit-app-region: no-drag;
background: transparent;
border-radius: 3px;
border: none;
color: #aaa;
cursor: default;
font-size: 14px;
font-weight: bold;
margin-left: 10px;
outline: none;
padding: 0;
padding: 7px 18px;
text-transform: uppercase;
}
/**
* Default button
*/
.Button.default {
color: #222;
background-color: rgba(153, 153, 153, 0.1);
}
.Button.default.dark {
color: #eee;
}
.Button.default:hover,
.Button.default:focus { /* Material design: focused */
background-color: rgba(153, 153, 153, 0.2);
}
.Button.default:active { /* Material design: pressed */
background-color: rgba(153, 153, 153, 0.4);
}
/**
* Flat button
*/
.Button.flat {
color: #222;
}
.Button.flat.dark {
color: #eee;
}
.Button.flat:hover,
.Button.flat:focus {
background-color: rgba(153, 153, 153, 0.2);
}
.Button.flat:active {
background-color: rgba(153, 153, 153, 0.4);
}
/**
* Raised button
*/
.Button.raised {
background-color: #2196f3;
color: #eee;
}
.Button.raised:hover,
.Button.raised:focus {
background-color: #38a0f5;
}
.Button.raised:active {
background-color: #51abf6;
}

View File

@@ -1,17 +0,0 @@
.PathSelector {
align-items: center;
display: flex;
width: 100%;
}
.PathSelector .label {
margin-right: 10px;
flex: 1 1 auto;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.PathSelector .input {
flex: 5 5 200px;
}

View File

@@ -1,18 +0,0 @@
.TextInput {
background: rgba(255, 255, 255, 0.8);
border-radius: 3px;
font-size: 14px;
outline: none;
padding: 3px 6px;
width: 200px;
-webkit-app-region: no-drag;
cursor: default;
}
.TextInput.light {
border: 1px solid rgba(0, 0, 0, 0.4);
}
.TextInput.dark {
border: 1px solid rgba(0, 0, 0, 0.8);
}

View File

@@ -1,17 +0,0 @@
.PreferencesPage {
color: rgba(255, 255, 255, 0.6);
margin: 0 20px;
}
.PreferencesSection:not(:last-child) {
margin-top: 20px;
margin-bottom: 40px;
}
.PreferencesSection .title {
color: rgba(255, 255, 255, 0.9);
}
.Preference:not(:last-child) {
margin-bottom: 10px;
}

View File

@@ -20,7 +20,7 @@ body {
}
.app {
color: #FFF;
color: #FAFAFA; /* grey50 */
font-family: BlinkMacSystemFont, 'Helvetica Neue', Helvetica, sans-serif;
font-size: 14px;
line-height: 1.5em;
@@ -91,9 +91,7 @@ table {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url('../MaterialIcons-Regular.woff2') format('woff2');
src: url('MaterialIcons-Regular.woff2') format('woff2');
}
.icon {
@@ -1025,3 +1023,19 @@ video::-webkit-media-text-track-container {
height: 32px;
margin: 4px 0 0 4px;
}
/**
* Use this class on Material UI components to get correct native app behavior:
*
* - Dragging the button should NOT drag the entire app window
* - The cursor should be default, not a pointer (hand) like on the web
*/
.control {
-webkit-app-region: no-drag;
cursor: default !important;
}
.control * {
cursor: default !important;
}

View File

@@ -3,22 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>WebTorrent Desktop</title>
<link rel="stylesheet" href="css/components/Button.css">
<link rel="stylesheet" href="css/components/PathSelector.css">
<link rel="stylesheet" href="css/components/TextInput.css">
<link rel="stylesheet" href="css/pages/PreferencesPage.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="main.css">
</head>
<body>
<!-- React prints a warning if you render to <body> directly -->
<div id='body'></div>
<!-- We can't just say src='...main.js', that breaks require()s -->
<script>
require('../build/renderer/main.js')
</script>
<script>require('../build/renderer/main.js')</script>
</body>
</html>