Skip to content

Commit

Permalink
Refactor: CSS responsive breakpoints (#178)
Browse files Browse the repository at this point in the history
* refactor: move src/index.css to src/styles/index.css

* style: improved stylelint configuration

* refactor: remove unnecessary screen option from the media query

* refactor: define several CSS breakpoint value variables

* refactor: js read the breakpoint values defined in scss

* refactor: remove some unconventional CSS breakpoint values from Header

* feat: make the Footer more in line with the design draft

* refactor: remove unconventional CSS breakpoint values from NFT components

* feat: make the TransactionInfoItem more in line with the design draft

* refactor: remove unconventional CSS breakpoint values from Script component

* feat: make the NFTInfo more in line with the design draft

* feat: make the TransactionParameters more in line with the design draft
  • Loading branch information
WhiteMinds authored Dec 21, 2023
1 parent ffd2157 commit 2619130
Show file tree
Hide file tree
Showing 98 changed files with 755 additions and 692 deletions.
15 changes: 5 additions & 10 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const package = require('./package.json')

module.exports = {
customSyntax: 'postcss-scss',
extends: ['stylelint-config-standard'],
extends: ['stylelint-config-standard', 'stylelint-config-css-modules'],
rules: {
'no-empty-source': null,
// Based on the discussion in https://github.com/Magickbase/ckb-explorer-public-issues/issues/442, we have decided to use lower camel case.
Expand All @@ -11,20 +11,12 @@ module.exports = {
'custom-property-pattern': null,
// This rule provides little benefit relative to the cost of implementing it, so it has been disabled.
'no-descending-specificity': null,

'selector-pseudo-class-no-unknown': [
true,
{
// to support `:global`
ignorePseudoClasses: ['global'],
},
],
},

overrides: [
{
files: ['*.scss', '**/*.scss'],
extends: ['stylelint-config-standard-scss'],
extends: ['stylelint-config-standard-scss', 'stylelint-config-css-modules'],
rules: {
'scss/dollar-variable-pattern': null,
'scss/at-rule-no-unknown': [
Expand All @@ -47,12 +39,15 @@ module.exports = {
plugins: ['stylelint-no-unsupported-browser-features'],
rules: {
'media-feature-range-notation': null,
// This is to support the syntax `@media (max-width: ${variables.mobileBreakPoint})`.
'media-query-no-invalid': null,
'plugin/no-unsupported-browser-features': [
true,
{
browsers: package.browserslist,
// TODO: Perhaps the browserslist should be adjusted to a more reasonable range, at least to a level that is compatible with CSS variables.
ignore: [
'css-grid',
'css-nesting',
'css-sticky',
'css-variables',
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@
"rxjs": "7.8.1",
"storybook": "7.5.3",
"stylelint": "^15.10.1",
"stylelint-config-standard": "^34.0.0",
"stylelint-config-standard-scss": "^11.0.0",
"stylelint-config-css-modules": "^4.3.0",
"stylelint-config-standard": "^35.0.0",
"stylelint-config-standard-scss": "^12.0.0",
"stylelint-config-styled-components": "^0.1.1",
"stylelint-no-unsupported-browser-features": "7.0.0",
"stylelint-processor-styled-components": "^1.10.0",
Expand Down
4 changes: 3 additions & 1 deletion src/components/Card/Card.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '../../styles/variables.module';

.card {
width: 100%;
height: auto;
Expand All @@ -20,7 +22,7 @@
border-radius: 0 0 4px 4px;
}

@media (width <= 750px) {
@media (width <= $mobileBreakPoint) {
padding: 0 16px;
box-shadow: 1px 1px 3px 0 #dfdfdf;
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/Card/CardCell.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '../../styles/variables.module';

.cardCell {
display: flex;
align-items: center;
Expand Down Expand Up @@ -35,7 +37,7 @@
min-width: 0;
}

@media (width <= 750px) {
@media (width <= $mobileBreakPoint) {
flex-direction: column;
justify-content: initial;
align-items: initial;
Expand Down
5 changes: 3 additions & 2 deletions src/components/Card/CardCellsLayout.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '../../styles/variables.module';
@value cardCell from "./CardCell.module.scss";

.cardCellsLayout {
Expand Down Expand Up @@ -55,7 +56,7 @@
}
}

@media (width <= 1200px) {
@media (width <= $extraLargeBreakPoint) {
flex-direction: column;
gap: 20px;

Expand All @@ -70,7 +71,7 @@
}
}

@media (width <= 750px) {
@media (width <= $mobileBreakPoint) {
gap: 0;
padding: 0;

Expand Down
4 changes: 3 additions & 1 deletion src/components/Card/CardHeader.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '../../styles/variables.module';

.cardHeader {
display: flex;
align-items: center;
Expand All @@ -16,7 +18,7 @@
color: #333;
}

@media (width <= 750px) {
@media (width <= $mobileBreakPoint) {
flex-direction: column;
justify-content: initial;
align-items: initial;
Expand Down
14 changes: 8 additions & 6 deletions src/components/Card/HashCardHeader.module.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
@import '../../styles/variables.module';

.hashCardHeader {
display: flex;
align-items: center;
justify-content: space-between;
height: 80px;

@media (width <= 750px) {
@media (width <= $mobileBreakPoint) {
height: 56px;
}

Expand All @@ -21,7 +23,7 @@
color: #000;
white-space: nowrap;

@media (width <= 750px) {
@media (width <= $mobileBreakPoint) {
font-size: 20px;
}
}
Expand All @@ -31,7 +33,7 @@
font-size: 18px;
color: #000;

@media (width <= 750px) {
@media (width <= $mobileBreakPoint) {
transform: translateY(2px);
}

Expand All @@ -44,7 +46,7 @@
.title + .hash {
margin-left: 20px;

@media (width <= 750px) {
@media (width <= $mobileBreakPoint) {
margin-left: 8px;
}
}
Expand All @@ -56,7 +58,7 @@
margin-left: 32px;
color: #999;

@media (width <= 750px) {
@media (width <= $mobileBreakPoint) {
gap: 12px;
margin-left: 8px;
}
Expand All @@ -72,7 +74,7 @@
color: var(--primary-color);
}

@media (width <= 750px) {
@media (width <= $mobileBreakPoint) {
width: 16px;
height: 16px;
}
Expand Down
11 changes: 6 additions & 5 deletions src/components/DecimalCapacity/styled.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from 'styled-components'
import variables from '../../styles/variables.module.scss'

export const DecimalPanel = styled.div`
display: flex;
Expand All @@ -8,7 +9,7 @@ export const DecimalPanel = styled.div`
.decimalUnit {
margin-left: 5px;
@media (max-width: 750px) {
@media (max-width: ${variables.mobileBreakPoint}) {
margin-bottom: 0;
}
}
Expand All @@ -20,11 +21,11 @@ export const DecimalPartPanel = styled.div`
props.fontSize ? props.fontSize : '14px'};
color: ${(props: { color?: string }) => (props.color ? props.color : '#999999')};
@media (max-width: 1000px) {
@media (max-width: ${variables.largeBreakPoint}) {
font-size: ${(props: { fontSize?: string }) => (props.fontSize ? props.fontSize : '11px')};
}
@media (max-width: 750px) {
@media (max-width: ${variables.mobileBreakPoint}) {
margin-bottom: 0;
}
`
Expand All @@ -35,11 +36,11 @@ export const DecimalZerosPanel = styled.div`
props.fontSize ? props.fontSize : '14px'};
color: ${(props: { color?: string }) => (props.color ? props.color : '#999999')};
@media (max-width: 1000px) {
@media (max-width: ${variables.largeBreakPoint}) {
font-size: ${(props: { fontSize?: string }) => (props.fontSize ? props.fontSize : '11px')};
}
@media (max-width: 750px) {
@media (max-width: ${variables.mobileBreakPoint}) {
margin-bottom: 0;
}
`
4 changes: 3 additions & 1 deletion src/components/DecimalCapacity/styles.module.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@import '../../styles/variables.module';

.integerPart {
font-size: 16px;

@media (width <= 1000px) {
@media (width <= $largeBreakPoint) {
font-size: 12px;
}
}
30 changes: 3 additions & 27 deletions src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { ReactComponent as ForumIcon } from './footer_forum.svg'
import { ReactComponent as Discord } from './footer_discord.svg'
import { getCurrentYear } from '../../utils/date'
import { FooterMenuPanel, FooterItemPanel, FooterImageItemPanel, FooterPanel } from './styled'
import { useIsMobile } from '../../hooks'
import { udtSubmitEmail } from '../../utils/util'

interface FooterLinkItem {
Expand Down Expand Up @@ -44,7 +43,6 @@ const FooterImageItem = ({ item }: { item: FooterLinkItem }) => {
}

export default memo(() => {
const isMobile = useIsMobile()
const [t] = useTranslation()
const Footers = useMemo<FooterLink[]>(
() => [
Expand Down Expand Up @@ -143,31 +141,9 @@ export default memo(() => {
))}
</div>
<div className="footerCommunity">
{isMobile ? (
<div>
{Footers[2].items.map(item => (
<FooterImageItem item={item} key={item.label} />
))}
</div>
) : (
<>
<div>
{Footers[2].items.slice(0, 3).map(item => (
<FooterImageItem item={item} key={item.label} />
))}
</div>
<div>
{Footers[2].items.slice(3, 6).map(item => (
<FooterImageItem item={item} key={item.label} />
))}
</div>
<div>
{Footers[2].items.slice(6).map(item => (
<FooterImageItem item={item} key={item.label} />
))}
</div>
</>
)}
{Footers[2].items.map(item => (
<FooterImageItem item={item} key={item.label} />
))}
</div>
</FooterMenuPanel>
<div className="footerCopyright">
Expand Down
Loading

1 comment on commit 2619130

@vercel
Copy link

@vercel vercel bot commented on 2619130 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.