Skip to content

Commit

Permalink
Merge pull request #156 from 1Hive/description-ellispsis
Browse files Browse the repository at this point in the history
Description ellispsis
  • Loading branch information
Corantin committed Jan 27, 2022
2 parents 7e62148 + 47a5319 commit 4ebd7d1
Show file tree
Hide file tree
Showing 17 changed files with 278 additions and 122 deletions.
42 changes: 21 additions & 21 deletions packages/react-app/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,30 @@ function App() {

return (
// Trigger sentry.io
<ErrorBoundary>
<WalletProvider>
<PageContextProvider>
<TransactionContextProvider>
<QuestsContextProvider>
<FilterContextProvider>
<Main
assetsUrl="/aragon-ui/"
layout={false}
scrollView={false}
theme={currentTheme ?? DEFAULT_THEME}
>
<HashRouter>
<WalletProvider>
<PageContextProvider>
<TransactionContextProvider>
<QuestsContextProvider>
<FilterContextProvider>
<Main
assetsUrl="/aragon-ui/"
layout={false}
scrollView={false}
theme={currentTheme ?? DEFAULT_THEME}
>
<HashRouter>
<ErrorBoundary>
<MainView toggleTheme={toggleTheme} currentTheme={currentTheme}>
<Routes />
</MainView>
</HashRouter>
</Main>
</FilterContextProvider>
</QuestsContextProvider>
</TransactionContextProvider>
</PageContextProvider>
</WalletProvider>
</ErrorBoundary>
</ErrorBoundary>
</HashRouter>
</Main>
</FilterContextProvider>
</QuestsContextProvider>
</TransactionContextProvider>
</PageContextProvider>
</WalletProvider>
);
}
export default process.env.NODE_ENV === 'development' ? hot(App) : App;
105 changes: 105 additions & 0 deletions packages/react-app/src/collapsable-block.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* eslint-disable react/destructuring-assignment */
import { Button, IconDown, IconUp, IconCopy } from '@1hive/1hive-ui';
import { ReactNode, useEffect, useState } from 'react';
import styled from 'styled-components';
import { useCopyToClipboard } from './hooks/use-copy-to-clipboard.hook';
import { GUpx } from './utils/css.util';

// #region StyledComponents

const IconColumnStyled = styled.div`
display: flex;
flex-direction: column;
margin-right: ${GUpx()};
`;

const CollapseButtonStyled = styled.a`
display: flex;
cursor: pointer;
text-decoration: none !important;
user-select: none;
flex-grow: 1;
`;

const CopyButtonStyled = styled(Button)`
border-color: #2c3a584d;
`;

const LineStyled = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
`;

const ContentWrapperStyled = styled.div`
padding-top: ${GUpx()};
`;

const LabelStyled = styled.span`
height: 100%;
`;

// #endregion

type Props = {
children: any;
label?: string;
visible?: boolean;
type?: 'image' | 'code' | 'default';
alt?: string;
};

export function CollapsableBlock(props: Props) {
const [isVisible, setVisible] = useState(props.visible);
const copyCode = useCopyToClipboard();

useEffect(() => setVisible(props.visible), [props.visible]);

const [content, setContent] = useState<ReactNode | undefined>();

useEffect(() => {
// eslint-disable-next-line jsx-a11y/alt-text
if (props.type === 'image') setContent(<img {...props} />);
else
setContent(props.children?.props?.children ? props.children.props.children : props.children);
}, [props, props.children]);

return (
<div>
<pre>
<LineStyled>
<CollapseButtonStyled onClick={() => setVisible(!isVisible)}>
<IconColumnStyled>
{isVisible ? (
<>
<IconDown size="tiny" />
<IconUp size="tiny" />
</>
) : (
<>
<IconUp size="tiny" />
<IconDown size="tiny" />
</>
)}
</IconColumnStyled>
<LabelStyled>
{isVisible ? 'Hide ' : 'Show '}
{props.label}
</LabelStyled>
</CollapseButtonStyled>
{isVisible && (
<CopyButtonStyled
onClick={() => copyCode(content)}
icon={<IconCopy />}
size="small"
label="Copy"
display="icon"
/>
)}
</LineStyled>
{isVisible && content ? <ContentWrapperStyled>{content}</ContentWrapperStyled> : <></>}
</pre>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ const AmountTokenWrapperStyled = styled.div`
display: flex;
justify-content: flex-start;
align-items: center;
${(props: any) => (props.wide ? 'width:100%;' : '')}
${(props: any) => (props.wide ? 'width:100%' : '')};
ul[role='listbox'] {
max-height: 200px;
overflow-y: auto;
}
`;

const IconEditStyled = styled(IconEdit)`
Expand Down Expand Up @@ -208,7 +213,7 @@ function AmountFieldInput({
{isLoading ? (
<Skeleton />
) : (
<AmountTokenWrapperStyled wide={wide}>
<AmountTokenWrapperStyled wide={wide} isEdit={isEdit}>
{amount !== undefined && (
<Outset horizontal>
{isEdit ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IconTooltip } from './icon-tooltip';

const FieldStyled = styled.div`
${({ compact }: any) => (!compact ? `margin-bottom:${GUpx(2)}` : '')};
${({ isLoading }: any) => (isLoading ? `width: 100%;` : '')};
${({ isLoading }: any) => (isLoading ? `width: 100%;` : 'max-width: 100%;')};
`;

const LabelStyled = styled.label`
Expand All @@ -23,12 +23,16 @@ const LabelStyled = styled.label`
const LineStyled = styled.div`
display: flex;
align-items: top;
max-width: 100%;
`;

const ContentWrapperStyled = styled.div`
display: flex;
align-items: center;
${(props: any) => (!props.compact ? 'min-height: 45px;' : '')}
div {
max-width: 100%;
}
`;

const SkeletonWrapperStyled = styled.div`
Expand Down
40 changes: 34 additions & 6 deletions packages/react-app/src/components/field-input/text-field-input.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { TextInput, Markdown } from '@1hive/1hive-ui';
import { noop } from 'lodash-es';
import React, { ReactNode } from 'react';
import { CollapsableBlock } from 'src/collapsable-block';
import { GUpx } from 'src/utils/css.util';
import styled from 'styled-components';
import { FieldInput } from './field-input';

// #region Styled

const MaxHeightStyled = styled.div`
const MaxLineStyled = styled.div`
margin-bottom: ${GUpx()};
display: -webkit-box;
-webkit-line-clamp: ${(props: any) => props.maxLine};
-webkit-box-orient: vertical;
overflow: hidden;
margin-bottom: 8px;
line-height: 1.5em;
${({ maxLine }: any) => (maxLine ? `max-height: ${maxLine * 1.5}em;` : '')}
overflow-wrap: anywhere;
p {
margin-top: 0 !important;
Expand Down Expand Up @@ -65,10 +68,35 @@ export default function TextFieldInput({
{isMarkDown ? (
<Markdown
normalized
content={value}
markdownToJsxOptions={(o: any) => ({
...o,
overrides: {
pre: {
component: CollapsableBlock,
props: {
label: 'block',
visible: !maxLine,
},
},
code: {
component: CollapsableBlock,
props: {
label: 'code block',
type: 'code',
visible: !maxLine,
},
},
img: {
component: CollapsableBlock,
props: {
label: 'image',
type: 'image',
visible: !maxLine,
},
},
},
})}
content={value}
/>
) : (
value
Expand All @@ -90,7 +118,7 @@ export default function TextFieldInput({
<div style={{ ...css, fontSize }}>
{maxLine ? (
<div>
<MaxHeightStyled maxLine={maxLine}>{readOnlyContent}</MaxHeightStyled>
<MaxLineStyled maxLine={maxLine}>{readOnlyContent}</MaxLineStyled>
{ellipsis}
</div>
) : (
Expand Down
42 changes: 22 additions & 20 deletions packages/react-app/src/components/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import { useTheme, GU, Link } from '@1hive/1hive-ui';
import { GUpx } from 'src/utils/css.util';
import styled from 'styled-components';

// #region StyledComponent

const FooterWrapper = styled.div`
display: flex;
const FooterContainerStyled = styled.div`
margin: auto;
background-color: ${(props: any) => props.background};
column-gap: 150px;
justify-content: center;
box-shadow: rgb(0 0 0 / 5%) 3px -2px 0px;
position: relative;
padding: 40px 24px;
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
a {
color: ${({ color }: any) => color} !important;
}
padding: ${GUpx(5)} ${GUpx(3)};
`;

const FooterColumn = styled.div`
text-align: center;
const FooterColumnStyled = styled.div`
padding: ${GUpx(2)};
`;

const FooterTitle = styled.div`
const FooterTitleStyled = styled.div`
display: flex;
flex-direction: center;
align-items: center;
Expand All @@ -42,9 +44,9 @@ const FooterLinkStyled = styled(Link)`
export default function footer() {
const theme = useTheme();
return (
<FooterWrapper background={theme.surface} color={theme.contentSecondary}>
<FooterColumn>
<FooterTitle>Community</FooterTitle>
<FooterContainerStyled background={theme.surface} color={theme.contentSecondary}>
<FooterColumnStyled>
<FooterTitleStyled>Community</FooterTitleStyled>
<FooterLinkStyled href="https://discord.gg/4fm7pgB" external>
Discord
</FooterLinkStyled>
Expand All @@ -60,15 +62,15 @@ export default function footer() {
<FooterLinkStyled href="https://forum.1hive.org/" external>
Forum
</FooterLinkStyled>
</FooterColumn>
<FooterColumn>
<FooterTitle>Documentation</FooterTitle>
</FooterColumnStyled>
<FooterColumnStyled>
<FooterTitleStyled>Documentation</FooterTitleStyled>
<FooterLinkStyled href="https://wiki.1hive.org/projects/quests" external>
Wiki
</FooterLinkStyled>
</FooterColumn>
<FooterColumn>
<FooterTitle>Feedback</FooterTitle>
</FooterColumnStyled>
<FooterColumnStyled>
<FooterTitleStyled>Feedback</FooterTitleStyled>
<FooterLinkStyled
href="https://github.com/1Hive/quests/issues/new?assignees=&labels=Feature&template=feature----feature_title-.md"
external
Expand All @@ -81,7 +83,7 @@ export default function footer() {
>
Report a bug
</FooterLinkStyled>
</FooterColumn>
</FooterWrapper>
</FooterColumnStyled>
</FooterContainerStyled>
);
}
6 changes: 3 additions & 3 deletions packages/react-app/src/components/modals/challenge-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import TextFieldInput from '../field-input/text-field-input';
import { Outset } from '../utils/spacer-util';
import { IconTooltip } from '../field-input/icon-tooltip';
import { getLastBlockDate } from '../../utils/date.utils';
import { ShowBalanceOf } from '../show-balance-of';
import { WalletBallance } from '../wallet-balance';

// #region StyledComponents

Expand Down Expand Up @@ -266,7 +266,7 @@ export default function ChallengeModal({ claim, challengeDeposit, onClose = noop
</OpenButtonWrapperStyled>
}
buttons={[
<ShowBalanceOf
<WalletBallance
askedTokenAmount={
isFeeDepositSameToken && challengeFee
? {
Expand All @@ -278,7 +278,7 @@ export default function ChallengeModal({ claim, challengeDeposit, onClose = noop
setIsEnoughBalance={setIsEnoughBalance}
/>,
challengeFee && !isFeeDepositSameToken && (
<ShowBalanceOf askedTokenAmount={challengeFee} setIsEnoughBalance={setIsEnoughBalance} />
<WalletBallance askedTokenAmount={challengeFee} setIsEnoughBalance={setIsEnoughBalance} />
),
<AmountFieldInput
key="challengeDeposit"
Expand Down

1 comment on commit 4ebd7d1

@vercel
Copy link

@vercel vercel bot commented on 4ebd7d1 Jan 27, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

Please sign in to comment.