-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
SNosenko
authored and
SNosenko
committed
Sep 29, 2021
1 parent
67cc96e
commit 555acb6
Showing
44 changed files
with
669 additions
and
1,353 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,78 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import cn from 'classnames'; | ||
import PointIcon from '../../icons/Point.icon'; | ||
import { DotProps, DotSettingProps } from '../../types/utils/dot.type'; | ||
import { PointIcon } from '../../icons/Point'; | ||
import { DotProps, DotSettingProps } from '../../types/utils/dot.types'; | ||
|
||
import styles from './index.module.css'; | ||
|
||
const Dot = React.forwardRef<SVGSVGElement, DotProps>((props, ref): React.ReactElement | null => { | ||
const { cx, cy, index, activeDot, dataKey, dotSettings } = props; | ||
const [windowWidth, setWindowWidth] = useState<number>(0); | ||
export const Dot = React.forwardRef<SVGSVGElement, DotProps>( | ||
( | ||
{ cx, cy, index, activeDot, dataKey, dotSettings, value, stroke }, | ||
ref, | ||
): React.ReactElement | null => { | ||
const [windowWidth, setWindowWidth] = useState<number>(0); | ||
|
||
const [height, setHeight] = useState<number>(0); | ||
const [width, setWidth] = useState<number>(0); | ||
const [option, setOption] = useState<DotSettingProps | null>(null); | ||
const [height, setHeight] = useState<number>(0); | ||
const [width, setWidth] = useState<number>(0); | ||
const [option, setOption] = useState<DotSettingProps | null>(null); | ||
|
||
useEffect(() => { | ||
let dotSetting: DotSettingProps = | ||
Array.isArray(dotSettings) && dotSettings.length > 0 | ||
? dotSettings.find(item => item.media && windowWidth < item.media) | ||
: dotSettings; | ||
useEffect(() => { | ||
let dotSetting: DotSettingProps = | ||
Array.isArray(dotSettings) && dotSettings.length > 0 | ||
? dotSettings.find(item => item.media && windowWidth < item.media) | ||
: dotSettings; | ||
|
||
if (Array.isArray(dotSettings) && dotSettings.length > 0 && !dotSetting) { | ||
dotSetting = dotSettings[dotSettings.length - 1]; | ||
} | ||
if (Array.isArray(dotSettings) && dotSettings.length > 0 && !dotSetting) { | ||
dotSetting = dotSettings[dotSettings.length - 1]; | ||
} | ||
|
||
setWindowWidth(window.innerWidth); | ||
setOption(dotSetting); | ||
}, [dotSettings, windowWidth]); | ||
setWindowWidth(window.innerWidth); | ||
setOption(dotSetting); | ||
}, [dotSettings, windowWidth]); | ||
|
||
useEffect(() => { | ||
if (!option) return; | ||
useEffect(() => { | ||
if (!option) return; | ||
|
||
if (typeof activeDot === 'number' && activeDot === index) { | ||
setHeight(option.height * option.scale); | ||
setWidth(option.width * option.scale); | ||
} else { | ||
setHeight(option.height * option.initScale); | ||
setWidth(option.width * option.initScale); | ||
} | ||
}, [activeDot, index, option]); | ||
if (typeof activeDot === 'number' && activeDot === index) { | ||
setHeight(option.height * option.scale); | ||
setWidth(option.width * option.scale); | ||
} else { | ||
setHeight(option.height * option.initScale); | ||
setWidth(option.width * option.initScale); | ||
} | ||
}, [activeDot, index, option]); | ||
|
||
if (!props.value) return null; | ||
if (!value) return null; | ||
|
||
return ( | ||
<g | ||
ref={ref} | ||
className={cn(styles.dot)} | ||
transform={`translate(${cx - width / 2}, ${cy - height / 2})`} | ||
> | ||
return ( | ||
<g | ||
className={cn(styles.dotWrap)} | ||
transform={`scale(${ | ||
activeDot === index ? option?.scale || 0 : option?.initScale || 0 | ||
})`} | ||
ref={ref} | ||
className={cn(styles.dot)} | ||
transform={`translate(${cx - width / 2}, ${cy - height / 2})`} | ||
> | ||
<svg | ||
className={cn( | ||
styles.dotItem, | ||
activeDot === index ? styles.dotActive : '', | ||
typeof activeDot === 'number' && activeDot !== index | ||
? styles.dotUnfocused | ||
: '', | ||
)} | ||
data-id={index} | ||
data-name={dataKey} | ||
width={option?.width || 0} | ||
height={option?.height || 0} | ||
<g | ||
className={cn(styles.dotWrap)} | ||
transform={`scale(${ | ||
activeDot === index ? option?.scale || 0 : option?.initScale || 0 | ||
})`} | ||
> | ||
<PointIcon fill={props?.stroke} /> | ||
</svg> | ||
<svg | ||
className={cn( | ||
styles.dotItem, | ||
activeDot === index ? styles.dotActive : '', | ||
typeof activeDot === 'number' && activeDot !== index | ||
? styles.dotUnfocused | ||
: '', | ||
)} | ||
data-id={index} | ||
data-name={dataKey} | ||
width={option?.width || 0} | ||
height={option?.height || 0} | ||
> | ||
<PointIcon fill={stroke} /> | ||
</svg> | ||
</g> | ||
</g> | ||
</g> | ||
); | ||
}); | ||
|
||
export default Dot; | ||
); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,17 @@ | ||
import React from 'react'; | ||
import { GradientProps, LinearGradientProps } from '../types/utils/gradient.type'; | ||
import { GradientProps, LinearGradientProps } from '../types/utils/gradient.types'; | ||
|
||
const LinearGradient = ({ id, gid, points }: LinearGradientProps): React.ReactElement => { | ||
export const LinearGradient = ({ id, gid, points }: LinearGradientProps): React.ReactElement => { | ||
return ( | ||
<linearGradient key={`${id}-${gid}`} id={`${id}-${gid}`} x1='0' y1='0' x2='0' y2='1'> | ||
{points.map((point: GradientProps, index: number) => { | ||
const key = `${id}${gid}-${index}`; | ||
return ( | ||
<stop | ||
key={key} | ||
offset={`${point.offset}%`} | ||
stopColor={point.stopColor} | ||
stopOpacity={point.stopOpacity} | ||
/> | ||
); | ||
})} | ||
{points.map((point: GradientProps, index: number) => ( | ||
<stop | ||
key={`${id}${gid}-${index.toString()}`} | ||
offset={`${point.offset}%`} | ||
stopColor={point.stopColor} | ||
stopOpacity={point.stopOpacity} | ||
/> | ||
))} | ||
</linearGradient> | ||
); | ||
}; | ||
|
||
export default LinearGradient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
@import '../../../../themes/src/default.css'; | ||
@import '../../../../vars//src//typography.css'; | ||
|
||
.tickText { | ||
fill: var(--color-light-text-primary); | ||
font-size: 16px; | ||
line-height: 22px; | ||
@mixin paragraph_primary_medium; | ||
} | ||
|
||
.circle { | ||
opacity: 0.3; | ||
fill: var(--color-dark-bg-primary); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.