筛选组件开发
This commit is contained in:
81
src/components/Range/index.module.scss
Normal file
81
src/components/Range/index.module.scss
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
|
||||
// 全局NutUI样式覆盖
|
||||
.nutRange {
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
|
||||
// .nut-range__bar-box {
|
||||
// margin: 0 !important;
|
||||
// padding: 0 !important;
|
||||
// }
|
||||
|
||||
// .nut-range__bar {
|
||||
// margin: 0 !important;
|
||||
// }
|
||||
}
|
||||
|
||||
.nutRangeHeader {
|
||||
line-height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
.nutRangeHeaderLeft {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.nutRangeHeaderTitle {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.nutRangeHeaderContent {
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #3c3c34;
|
||||
}
|
||||
}
|
||||
|
||||
.rangeWrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 5px;
|
||||
height: 44px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e0e0e0;
|
||||
padding: 0 10px;
|
||||
.rangeHandle {
|
||||
:global(.nut-range-mark) {
|
||||
padding-top: 28px;
|
||||
left: 8px;
|
||||
}
|
||||
:global(.nut-range-bar) {
|
||||
background: #000000;
|
||||
height: 6px;
|
||||
}
|
||||
:global(.nut-range-button) {
|
||||
border: none;
|
||||
box-shadow: 0 6px 13px 0 rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
:global(.nut-range-tick) {
|
||||
background: #3c3c3c;
|
||||
height: 4px !important;
|
||||
width: 4px !important;
|
||||
}
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
.rangeWrapperMin,
|
||||
.rangeWrapperMax {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
.ntrp-range {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
user-select: none;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
margin-right: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
color: #000;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
&__slider-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
&__labels {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
&__track-container {
|
||||
position: relative;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
&__track {
|
||||
position: relative;
|
||||
height: 40px;
|
||||
background: #fff;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
&__markers {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
&__marker {
|
||||
position: absolute;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
background: #e0e0e0;
|
||||
border-radius: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
&__nutui-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 2;
|
||||
|
||||
// 隐藏NutUI的默认标签
|
||||
.nut-range__label {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
// 隐藏默认的轨道背景
|
||||
.nut-range__bar-box {
|
||||
background: transparent !important;
|
||||
height: 6px !important;
|
||||
border-radius: 3px !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
// 隐藏默认的轨道
|
||||
.nut-range__bar {
|
||||
background: transparent !important;
|
||||
height: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
// 自定义活动轨道(黑色填充条)
|
||||
.nut-range__bar--active {
|
||||
background: #000 !important;
|
||||
height: 6px !important;
|
||||
border-radius: 3px !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
// 自定义滑块手柄样式
|
||||
.nut-range__button {
|
||||
width: 24px !important;
|
||||
height: 24px !important;
|
||||
background: #fff !important;
|
||||
border: 2px solid #000 !important;
|
||||
border-radius: 50% !important;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
|
||||
top: 50% !important;
|
||||
transform: translate(-50%, -50%) !important;
|
||||
transition: all 0.1s ease !important;
|
||||
|
||||
&:hover {
|
||||
transform: translate(-50%, -50%) scale(1.1) !important;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translate(-50%, -50%) scale(1.15) !important;
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25) !important;
|
||||
}
|
||||
}
|
||||
|
||||
// 确保滑块在正确位置
|
||||
.nut-range__button-wrapper {
|
||||
top: 50% !important;
|
||||
transform: translateY(-50%) !important;
|
||||
}
|
||||
}
|
||||
|
||||
// 响应式设计
|
||||
@media (max-width: 480px) {
|
||||
&__track {
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
&__nutui-wrapper {
|
||||
.nut-range__button {
|
||||
width: 20px !important;
|
||||
height: 20px !important;
|
||||
}
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 全局NutUI样式覆盖
|
||||
.nut-range {
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
|
||||
.nut-range__bar-box {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.nut-range__bar {
|
||||
margin: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.ntrp-range__header {
|
||||
line-height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
.ntrp-range__header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.ntrp-range__title {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.ntrp-range__content {
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #3c3c34;
|
||||
}
|
||||
}
|
||||
|
||||
.rangeWrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 5px;
|
||||
height: 44px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e0e0e0;
|
||||
padding: 0 10px;
|
||||
.rangeHandle {
|
||||
.nut-range-mark {
|
||||
padding-top: 28px;
|
||||
}
|
||||
.nut-range-bar {
|
||||
background: #000000;
|
||||
height: 6px;
|
||||
}
|
||||
.nut-range-button {
|
||||
border: none;
|
||||
box-shadow: 0 6px 13px 0 rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.nut-range-tick {
|
||||
background: #3c3c3c;
|
||||
height: 4px !important;
|
||||
width: 4px !important;
|
||||
}
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
.rangeWrapper__min,
|
||||
.rangeWrapper__max {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useState, useEffect, useMemo } from "react";
|
||||
import { Range } from "@nutui/nutui-react-taro";
|
||||
import "./index.scss";
|
||||
import styles from "./index.module.scss";
|
||||
|
||||
interface RangeProps {
|
||||
min?: number;
|
||||
@@ -48,18 +48,18 @@ const NtrpRange: React.FC<RangeProps> = ({
|
||||
}, [currentValue, min, max]);
|
||||
|
||||
return (
|
||||
<div className="ntrp-range">
|
||||
<div className="ntrp-range__header">
|
||||
<div className="ntrp-range__header-left">
|
||||
<div className={styles.nutRange}>
|
||||
<div className={styles.nutRangeHeader}>
|
||||
<div className={styles.nutRangeHeaderLeft}>
|
||||
<div className="ntrp-range__icon">icon</div>
|
||||
<h3 className="ntrp-range__title">NTRP水平区间</h3>
|
||||
<h3 className={styles.nutRangeHeaderTitle}>NTRP水平区间</h3>
|
||||
</div>
|
||||
<p className="ntrp-range__content">{rangContent}</p>
|
||||
<p className={styles.nutRangeHeaderContent}>{rangContent}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div className="rangeWrapper">
|
||||
<span className="rangeWrapper__min">{min}</span>
|
||||
<div className={styles.rangeWrapper}>
|
||||
<span className={styles.rangeWrapperMin}>{min}</span>
|
||||
<Range
|
||||
range
|
||||
min={min}
|
||||
@@ -69,14 +69,14 @@ const NtrpRange: React.FC<RangeProps> = ({
|
||||
onChange={handleChange}
|
||||
disabled={disabled}
|
||||
defaultValue={[min, max]}
|
||||
className="rangeHandle"
|
||||
className={styles.rangeHandle}
|
||||
maxDescription={null}
|
||||
minDescription={null}
|
||||
currentDescription={null}
|
||||
marks={marks}
|
||||
style={{ color: "gold" }}
|
||||
/>
|
||||
<span className="rangeWrapper__max">{max}</span>
|
||||
<span className={styles.rangeWrapperMax}>{max}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user