Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: APP-2449 - DAO Header Following status #37

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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