Skip to content

Commit

Permalink
Add stylelint (testing impacts) (#2524)
Browse files Browse the repository at this point in the history
* Add stylelint (testing impacts)

* "defaultSeverity": "warning"

* Cleanup Table styles

* Default parser
  • Loading branch information
jacogr authored Apr 7, 2020
1 parent 6921744 commit 978c83d
Show file tree
Hide file tree
Showing 14 changed files with 915 additions and 237 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-any.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
pr:
strategy:
matrix:
step: ['lint', 'test', 'build:code', 'build:i18n']
step: ['lint', 'lint:css', 'test', 'build:code', 'build:i18n']
name: ${{ matrix.step }}
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 7 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": [
"stylelint-config-recommended",
"stylelint-config-styled-components"
],
"defaultSeverity": "warning"
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"clean": "polkadot-dev-clean-build",
"clean:i18n": "rm -rf packages/apps/public/locales/en && mkdir -p packages/apps/public/locales/en",
"lint": "polkadot-dev-run-lint",
"lint:css": "stylelint './packages/**/src/**/*.tsx'",
"postinstall": "polkadot-dev-yarn-only",
"test": "polkadot-dev-run-test packages/page-claims/src",
"start": "yarn clean && cd packages/apps && webpack --config webpack.config.js"
Expand All @@ -54,6 +55,9 @@
"i18next-scanner": "^2.11.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"stylelint": "^13.3.0",
"stylelint-config-recommended": "^3.0.0",
"stylelint-config-styled-components": "^0.1.1",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-plugin-serve": "^0.12.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/src/Apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default React.memo(styled(Apps)`
a.apps--SideBar-Item-NavLink-active {
background: #f5f5f5;
border-radius: 0.28571429rem 0 0 0.28571429rem;
// border-bottom: 2px solid transparent;
/* border-bottom: 2px solid transparent; */
color: #3f3f3f;
&:hover {
Expand Down
4 changes: 2 additions & 2 deletions packages/page-claims/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ const Signature = styled.textarea`
color: rgba(0, 0, 0, 0.5);
}
&:-ms-input-placeholder {
&::-ms-input-placeholder {
color: rgba(0, 0, 0, 0.5);
}
&::-ms-input-placeholder {
&:-ms-input-placeholder {
color: rgba(0, 0, 0, 0.5);
}
`;
Expand Down
42 changes: 21 additions & 21 deletions packages/page-contracts/src/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,27 @@ export default React.memo(styled(Messages)`
background: #e8f4ff;
}
&.disabled {
opacity: 1 !important;
background: #eee !important;
color: #555 !important;
}
.accessory {
width: 3rem;
display: flex;
align-items: center;
justify-content: center;
.execute {
display: none;
background: transparent;
font-size: 1.5rem;
margin: 0;
padding: 0;
}
}
&:hover {
.accessory .execute {
display: block;
Expand All @@ -201,26 +222,5 @@ export default React.memo(styled(Messages)`
font-weight: normal;
}
}
.accessory {
width: 3rem;
display: flex;
align-items: center;
justify-content: center;
.execute {
display: none;
background: transparent;
font-size: 1.5rem;
margin: 0;
padding: 0;
}
}
&.disabled {
opacity: 1 !important;
background: #eee !important;
color: #555 !important;
}
}
`);
2 changes: 1 addition & 1 deletion packages/page-js/src/Output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default React.memo(styled(Output)`
.logs-container {
flex: 1;
overflow: auto;;
overflow: auto;
}
.logs-content {
Expand Down
6 changes: 5 additions & 1 deletion packages/page-staking/src/Overview/Address/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ interface StakingState {
stakeOwn?: BN;
}

/* stylelint-disable */
const PERBILL_PERCENT = 10_000_000;
/* stylelint-enable */

function expandInfo ({ exposure, validatorPrefs }: DeriveStakingQuery): StakingState {
let nominators: [string, Balance][] = [];
let stakeTotal: BN | undefined;
Expand All @@ -60,7 +64,7 @@ function expandInfo ({ exposure, validatorPrefs }: DeriveStakingQuery): StakingS

return {
commission: commission
? `${(commission.toNumber() / 10_000_000).toFixed(2)}%`
? `${(commission.toNumber() / PERBILL_PERCENT).toFixed(2)}%`
: undefined,
nominators,
stakeOther,
Expand Down
4 changes: 2 additions & 2 deletions packages/page-staking/src/Targets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import { useTranslation } from '../translate';
import Summary from './Summary';
import Validator from './Validator';

const PERBILL = new BN(1_000_000_000);

interface Props {
className?: string;
}
Expand All @@ -34,6 +32,8 @@ interface AllInfo {

type SortBy = 'rankOverall' | 'rankBondOwn' | 'rankBondOther' | 'rankBondTotal' | 'rankComm';

const PERBILL = new BN(1_000_000_000);

function sortValidators (list: ValidatorInfo[]): ValidatorInfo[] {
return list
.sort((a, b): number => b.commissionPer - a.commissionPer)
Expand Down
17 changes: 9 additions & 8 deletions packages/react-components/src/AddressToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ export default React.memo(styled(AddressToggle)`
box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.15);
}
&.isAye {
cursor: move;
.ui--AddressToggle-address {
filter: none;
opacity: 1;
}
}
.ui--AddressToggle-address,
.ui--AddressToggle-toggle {
flex: 1;
Expand All @@ -126,4 +118,13 @@ export default React.memo(styled(AddressToggle)`
margin-top: 0.1rem;
text-align: right;
}
&.isAye {
cursor: move;
.ui--AddressToggle-address {
filter: none;
opacity: 1;
}
}
`);
142 changes: 141 additions & 1 deletion packages/react-components/src/Table/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import React from 'react';
import styled from 'styled-components';
import { isString } from '@polkadot/util';

import Spinner from '../Spinner';
Expand Down Expand Up @@ -31,4 +32,143 @@ function Body ({ children, className, empty, isEmpty }: Props): React.ReactEleme
);
}

export default React.memo(Body);
export default React.memo(styled(Body)`
td {
border-top: 1px solid #e6e6e6;
padding: 0.75rem 1rem;
text-align: left;
vertical-align: middle;
&:first-child {
border-left: 1px solid #e6e6e6;
}
&:last-child {
border-right: 1px solid #e6e6e6;
}
label {
display: block !important;
white-space: nowrap;
}
i.icon {
cursor: pointer;
}
div.empty {
opacity: 0.6;
padding: 0.25rem;
}
.ui--Spinner {
margin: 0 auto;
.text {
margin-bottom: 0;
}
}
&:hover label {
opacity: 1;
}
&.address {
min-width: 11rem;
padding: 0.85rem 1rem;
}
&.button {
text-align: right;
vertical-align: middle;
white-space: nowrap;
}
&.combined {
border-top-width: 0;
}
&.hash {
font-family: monospace;
}
&.number {
text-align: right;
}
&.relative {
position: relative;
}
&.overflow {
max-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
&.together {
white-space: nowrap;
}
&.top {
vertical-align: top;
}
&.middle {
text-align: center;
}
&.mini {
padding: 0 0.75rem 0 0;
white-space: nowrap;
}
&.favorite i.icon.isSelected {
color: darkorange;
}
}
tr {
background: white;
&.isHighlight td {
background: #ffffed;
}
&:last-child td {
border-bottom: 1px solid #e6e6e6;
}
&:first-child {
td:first-child {
border-radius: 0.25rem 0 0 0;
}
td:last-child {
border-radius: 0 0.25rem 0 0;
}
}
&:last-child {
td:first-child {
border-radius: 0 0 0 0.25rem;
}
td:last-child {
border-radius: 0 0 0.25rem 0;
}
}
&:not(:hover) {
.ui.button:not(.isIcon):not(.disabled) {
background: #eee !important;
color: #555 !important;
}
.ui.toggle.checkbox input:checked~.box:before,
.ui.toggle.checkbox input:checked~label:before {
background-color: #eee !important;
}
}
}
`);
40 changes: 39 additions & 1 deletion packages/react-components/src/Table/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import React from 'react';
import styled from 'styled-components';

interface Props {
className?: string;
Expand Down Expand Up @@ -41,4 +42,41 @@ function Head ({ className, filter, header, isEmpty }: Props): React.ReactElemen
);
}

export default React.memo(Head);
export default React.memo(styled(Head)`
th {
color: rgba(78, 78, 78, .66);
font-family: sans-serif;
font-weight: 100;
padding: 0.75rem 1rem 0.25rem;
text-align: right;
vertical-align: baseline;
white-space: nowrap;
h1, h2 {
font-size: 1.75rem;
}
&.address {
padding-left: 3rem;
text-align: left;
}
&.isClickable {
border-bottom: 2px solid transparent;
cursor: pointer;
}
&.start {
text-align: left;
}
}
tr {
background: transparent;
text-transform: lowercase;
&.filter th {
padding: 0;
}
}
`);
Loading

0 comments on commit 978c83d

Please sign in to comment.