Skip to content

Commit

Permalink
Feat: APP-2449 - DAO Header Following status (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabricevladimir authored Oct 13, 2023
1 parent 42a8b82 commit fd7094c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- `HeaderDao` favorited indicator to labelled button
- `HeaderDao` description line clamp indicator icon

## [0.3.1] - 2023-10-12

### Changed
Expand Down
2 changes: 2 additions & 0 deletions src/components/headers/headerDao.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Dao.args = {
translation: {
readMore: 'Read more',
readLess: 'Read less',
follow: 'follow',
following: 'following',
},
links: [
{
Expand Down
48 changes: 28 additions & 20 deletions src/components/headers/headerDao.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ import { styled } from 'styled-components';
import { useScreen } from '../../hooks';
import { shortenAddress, shortenDaoUrl } from '../../utils';
import { AvatarDao } from '../avatar';
import { ButtonIcon, ButtonText } from '../button';
import { ButtonText } from '../button';
import { Dropdown } from '../dropdown';
import {
IconBlock,
IconChevronDown,
IconCommunity,
IconCopy,
IconFavoriteDefault,
IconFavoriteSelected,
IconFlag,
} from '../icons';
import { IconBlock, IconCheckmark, IconChevronDown, IconChevronUp, IconCommunity, IconCopy, IconFlag } from '../icons';
import { Link } from '../link';
import { ListItemLink } from '../listItem';

const DEFAULT_LINES_SHOWN = 2;
const DEFAULT_LINKS_SHOWN = 3;
const DEFAULT_TRANSLATIONS: HeaderDaoProps['translation'] = {
follow: 'Follow',
following: 'Following',
readLess: 'Read less',
readMore: 'Read more',
};

export type HeaderDaoProps = {
daoName: string;
Expand All @@ -30,14 +28,16 @@ export type HeaderDaoProps = {
created_at: string;
daoChain: string;
daoType: string;
favorited?: boolean;
following?: boolean;
links?: Array<{
label: string;
href: string;
}>;
translation?: {
readMore: string;
readLess: string;
follow: string;
following: string;
};
onCopy?: (input: string) => void;
onFavoriteClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
Expand All @@ -57,12 +57,14 @@ export const HeaderDao: React.FC<HeaderDaoProps> = ({
created_at,
daoChain,
daoType,
favorited = false,
following = false,
links = [],
translation,
translation = {},
onCopy,
onFavoriteClick,
}) => {
const labels = { ...DEFAULT_TRANSLATIONS, ...translation };

const [showAll, setShowAll] = useState(true);
const [shouldClamp, setShouldClamp] = useState(false);

Expand Down Expand Up @@ -156,11 +158,15 @@ export const HeaderDao: React.FC<HeaderDaoProps> = ({
</Description>
{shouldClamp && (
<Link
label={
showAll
? `${translation?.readLess ?? 'Read less'} ↑`
: `${translation?.readMore ?? 'Read more'} ↓`
}
{...(showAll
? {
label: labels.readLess,
iconRight: <IconChevronUp />,
}
: {
label: labels.readMore,
iconRight: <IconChevronDown />,
})}
className="ft-text-base"
onClick={() => setShowAll((prevState) => !prevState)}
/>
Expand Down Expand Up @@ -221,12 +227,14 @@ export const HeaderDao: React.FC<HeaderDaoProps> = ({
}))}
/>
)}
<ButtonIcon
icon={favorited ? <IconFavoriteSelected /> : <IconFavoriteDefault />}
<ButtonText
onClick={onFavoriteClick}
mode="secondary"
size="large"
bgWhite
{...(following
? { iconLeft: <IconCheckmark />, label: labels.following }
: { label: labels.follow })}
/>
</ActionContainer>
</ActionWrapper>
Expand Down

0 comments on commit fd7094c

Please sign in to comment.