Skip to content
Open
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
3 changes: 2 additions & 1 deletion frontend/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
"@tanstack/react-query": "4.3.3",
"@tanstack/react-query-devtools": "4.3.3",
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
"buffer": "^6.0.3",
"@types/jest": "^29.1.2",
"@types/node": "^18.8.5",
"@types/react": "^18.0.21",
"@types/react-blockies": "^1.4.1",
"@types/react-copy-to-clipboard": "^5.0.4",
"@types/react-dom": "^18.0.6",
"@types/react-router-dom": "^5.3.3",
"buffer": "^6.0.3",
"bulma": "0.9.3",
"bulma-popover": "^1.1.1",
"classnames": "^2.2.6",
Expand Down
1 change: 0 additions & 1 deletion frontend/packages/client/src/App.sass
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import url('https://fonts.googleapis.com/css?family=DM+Sans:regular,bold,italic&subset=latin,latin-ext')
@charset "utf-8"

// Set brand colors
Expand Down
9 changes: 8 additions & 1 deletion frontend/packages/client/src/components/CommunityLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ export default function CommunityLinks({
discordUrl,
githubUrl,
} = {}) {
const showTitle = [
instagramUrl,
twitterUrl,
websiteUrl,
discordUrl,
githubUrl,
].every((val) => !!val);
return (
<div className="columns my-0 is-multiline">
<Title className="column is-12 py-0">Links</Title>
{showTitle && <Title className="column is-12 py-0">Links</Title>}
{websiteUrl && (
<a
className="column pt-0 pb-1 is-12 is-flex is-align-items-center has-text-black"
Expand Down
34 changes: 34 additions & 0 deletions frontend/packages/client/src/components/CustomTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { forwardRef } from 'react';
import { Svg } from '@cast/shared-components';
import {
Flex,
HStack,
Tab,
useMultiStyleConfig,
useTab,
} from '@chakra-ui/react';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const CustomTab = forwardRef<HTMLElement, any>((props, ref) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add an interface above to define the props for the component instead of using any?

// 1. Reuse the `useTab` hook
const tabProps = useTab({ ...props, ref });
const isSelected = !!tabProps['aria-selected'];

// 2. Hook into the Tabs `size`, `variant`, props
const styles = useMultiStyleConfig('Tabs', tabProps);

return (
<Tab __css={styles.tab} {...tabProps}>
<HStack spacing={2}>
<Flex {...(isSelected ? { fontWeight: 'bold' } : {})}>
{tabProps.children}
</Flex>
{isSelected ? (
<Svg name="Star" width="13" height="13" fill="black" />
) : null}
Comment on lines +26 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of ternary here you could use isSelected && <Svg />

</HStack>
</Tab>
);
});

export default CustomTab;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { JoinCommunityButton } from 'components';
import { useMediaQuery, useVotesForAddress } from 'hooks';
import BackButton from './BackButton';
import ShareDropdown from './ShareDropdown';
import ShareDropdown from './ShareProposalDropdown';

const HeaderNavigation = ({
communityId,
Expand Down
92 changes: 0 additions & 92 deletions frontend/packages/client/src/components/Proposal/ShareDropdown.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ShareDropdown } from 'components';
import { FRONTEND_URL } from 'const';
import { Box } from '@chakra-ui/react';

interface ShareProposalDropdownProps {
communityId: string;
proposalId: string;
proposalName: string;
userVoted: boolean;
}
const ShareProposalDropdown: React.FC<ShareProposalDropdownProps> = (
{
communityId,
proposalId,
proposalName = '',
userVoted,
} = {} as ShareProposalDropdownProps
) => {
const proposalUrl = `${FRONTEND_URL}/#/community/${communityId}/proposal/${proposalId}`;

const twitterPost = `https://twitter.com/intent/tweet?text=${encodeURIComponent(
userVoted
? `I just voted on ${proposalName} on CAST! ${proposalUrl}`
: `Check out ${proposalName} on CAST! ${proposalUrl}`
)} `;
Comment on lines +21 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be

const twitterPost = userVoted
      ? `I just voted on ${proposalName} on CAST! ${proposalUrl}`
      : `Check out ${proposalName} on CAST! ${proposalUrl}`

because below in the component you using the twitter intent url again


return (
<Box ml={4}>
<ShareDropdown
isIconOnly={false}
twitterShareString={twitterPost}
copyString={proposalUrl}
offset={[-85, 2]}
direction="rtl"
/>
</Box>
);
};
export default ShareProposalDropdown;
96 changes: 96 additions & 0 deletions frontend/packages/client/src/components/ShareDropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { CopyToClipboard } from 'react-copy-to-clipboard';
import { Svg } from '@cast/shared-components';
import { useMediaQuery } from 'hooks';
import {
Flex,
Link,
Menu,
MenuButton,
MenuDivider,
MenuItem,
MenuList,
Text,
} from '@chakra-ui/react';

interface ShareDropdownProps {
twitterShareString: string;
copyString: string;
isIconOnly?: boolean;
offset?: [number, number];
direction?: 'ltr' | 'rtl';
}
const ShareDropdown: React.FC<ShareDropdownProps> = ({
isIconOnly = true,
twitterShareString = '',
copyString = '',
offset,
direction,
}) => {
const isBiggerThanMobile = useMediaQuery();

const twitterPost = `https://twitter.com/intent/tweet?text=${encodeURIComponent(
twitterShareString
)} `;

return (
<>
<Menu offset={offset} direction={direction}>
<MenuButton
transition="all 0.2s"
borderWidth="1px"
borderColor="black"
_hover={{ borderColor: 'blackAlpha.600' }}
maxH={isBiggerThanMobile ? '40px' : '32px'}
{...(isIconOnly
? { px: '13px', py: '21px', borderRadius: 'full' }
: {
px: 4,
py: 2,
borderRadius: '3xl',
})}
>
<Flex alignItems="center">
<Svg name="Share" />
{!isIconOnly ? (
<Text
fontWeight="bold"
ml={3}
fontSize={isBiggerThanMobile ? 'md' : 'sm'}
>
Share
</Text>
) : null}
</Flex>
</MenuButton>
<MenuList borderRadius="2xl" maxW="192px" minW="192px">
<MenuItem display="flex" alignItems="center" minHeight="48px" pl={3}>
<CopyToClipboard text={copyString} onCopy={() => {}}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should utilize useClipboard from Chakra instead this will allow us to remove react-copy-to-clipboard

<Flex alignItems="center">
<Svg name="Copy" />
<Text fontWeight="bold" ml={3}>
Copy Link
</Text>
</Flex>
</CopyToClipboard>
</MenuItem>
<MenuDivider border="light" borderColor="grey.300" my={0} />
<MenuItem display="flex" alignItems="center" minHeight="48px" pl={3}>
<Svg name="Twitter" />
<Link
href={twitterPost}
target="_blank"
rel="noreferrer noopenner"
className="twitter-share-button"
fontWeight="bold"
ml={3}
_hover={{ textDecoration: 'none' }}
>
Tweet
</Link>
</MenuItem>
</MenuList>
</Menu>
</>
);
};
export default ShareDropdown;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component is reused in the proposal copy and in the user profile

Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
export default function Tooltip({
interface TooltipProps {
enabled: boolean;
position: 'left' | 'right' | 'top' | 'bottom';
text: string;
children?: React.ReactNode;
classNames: string;
alwaysVisible: boolean;
}
const Tooltip: React.FC<TooltipProps> = ({
enabled = true,
position,
text,
children,
classNames = '',
alwaysVisible = false,
}) {
}) => {
const positionConfig = {
left: 'has-tooltip-left',
right: 'has-tooltip-right',
Expand All @@ -23,4 +31,6 @@ export default function Tooltip({
{children}
</span>
);
}
};

export default Tooltip;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turning into TS

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ShareDropdown } from 'components';
import { FRONTEND_URL } from 'const';
import { Box } from '@chakra-ui/react';

interface ShareProfileDropdownProps {
userAddr: string;
}
const ShareProfileDropdown: React.FC<ShareProfileDropdownProps> = ({
userAddr,
}) => {
const profileUrl = `${FRONTEND_URL}/#/profile?addr=${userAddr}`;

const twitterPost = `https://twitter.com/intent/tweet?text=${encodeURIComponent(
`Check at my profile in ${profileUrl} on CAST! `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`Check at my profile in ${profileUrl} on CAST! `
`Check at my profile on CAST! ${profileUrl}`

Check with product they may have better copy that we can use for the tweet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here as well I don't think you need the url in the string because ShareDropdown uses the twitter url and encodes the string passed to the component

)} `;

return (
<Box ml={4}>
<ShareDropdown
isIconOnly={true}
twitterShareString={twitterPost}
copyString={profileUrl}
/>
</Box>
);
};
export default ShareProfileDropdown;
Loading