Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit d5265a7

Browse files
authored
style(comments): header / footer redesign (#1062)
* refactor(comments): isSolution & isAuthorUpvoted concept * chore(comments): adjust styles * chore(comments): adjust styles wip * chore(comments): adjust styles wip * chore(comments): replies toggler concept * chore(comments): adjust toggler style * refactor(comments): list header icons * refactor(comments): list footer icons
1 parent 27b9b21 commit d5265a7

32 files changed

+497
-284
lines changed
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

public/icons/static/shape/lock.svg

Lines changed: 1 addition & 0 deletions
Loading

public/icons/static/shape/quote.svg

Lines changed: 1 addition & 0 deletions
Loading

src/components/Common/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import styled from 'styled-components'
33
import type { TSpace } from '@/spec'
44

55
export const Br = styled.div<TSpace>`
6-
margin-top: ${({ top }) => `${top}px` || 0};
7-
margin-bottom: ${({ bottom }) => `${bottom}px` || 0};
6+
margin-top: ${({ top }) => `${top || 0}px`};
7+
margin-bottom: ${({ bottom }) => `${bottom || 0}px`};
88
`
99
export const Space = styled.span<TSpace>`
1010
margin-left: ${({ left }) => `${left}px` || 0};

src/components/Switcher/IconSwitcher.js

Lines changed: 0 additions & 81 deletions
This file was deleted.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
*
3+
* IconSwitcher
4+
*
5+
*/
6+
7+
import React from 'react'
8+
import { findIndex, propEq } from 'ramda'
9+
10+
import { buildLog, nilOrEmpty } from '@/utils'
11+
import Tooltip from '@/components/Tooltip'
12+
13+
import {
14+
Wrapper,
15+
AccessZone,
16+
Tabs,
17+
DescText,
18+
Icon,
19+
Label,
20+
Slider,
21+
} from './styles/icon_selector'
22+
23+
/* eslint-disable-next-line */
24+
const log = buildLog('c:IconSwitcher:index')
25+
26+
type TItem = {
27+
iconSrc?: string
28+
localIcon?: React.ReactNode
29+
key: string
30+
desc?: string
31+
}
32+
33+
type TIconComp = {
34+
item: TItem
35+
activeKey: string
36+
}
37+
38+
type TTabLabel = {
39+
item: TItem
40+
activeKey: string
41+
onChange: (item: TItem) => void
42+
}
43+
44+
const TabLabel: React.FC<TTabLabel> = ({ item, activeKey, onChange }) => {
45+
if (!item.desc) {
46+
return (
47+
<Label onClick={() => onChange(item)}>
48+
{!nilOrEmpty(item.localIcon) && <>{item.localIcon}</>}
49+
{!nilOrEmpty(item.iconSrc) && (
50+
<Icon src={item.iconSrc} checked={activeKey === item.key} />
51+
)}
52+
</Label>
53+
)
54+
}
55+
56+
return (
57+
<Tooltip
58+
content={<DescText>{item.desc}</DescText>}
59+
placement="bottom"
60+
delay={500}
61+
noPadding
62+
>
63+
<Label onClick={() => onChange(item)}>
64+
{!nilOrEmpty(item.localIcon) && <>{item.localIcon}</>}
65+
{!nilOrEmpty(item.iconSrc) && (
66+
<Icon src={item.iconSrc} checked={activeKey === item.key} />
67+
)}
68+
</Label>
69+
</Tooltip>
70+
)
71+
}
72+
73+
type TProps = {
74+
items: TItem[]
75+
activeKey: string
76+
onChange: (item: TItem) => void
77+
}
78+
79+
const IconSwitcher: React.FC<TProps> = ({ items, activeKey, onChange }) => {
80+
const slideIndex = findIndex(propEq('key', activeKey), items)
81+
82+
return (
83+
<Wrapper testid="selectors">
84+
<AccessZone />
85+
<Tabs>
86+
{items.map((item) => (
87+
<TabLabel
88+
key={item.key}
89+
item={item}
90+
activeKey={activeKey}
91+
onChange={onChange}
92+
/>
93+
))}
94+
<Slider index={slideIndex} />
95+
</Tabs>
96+
</Wrapper>
97+
)
98+
}
99+
100+
export default React.memo(IconSwitcher)

0 commit comments

Comments
 (0)