Skip to content

Make UI responsive #314

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

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
143 changes: 86 additions & 57 deletions src/components/banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ export const Banner = (props: IBannerProps) => {
const defaultTitleStyles = {
fontSize: '20px',
fontWeight: 'bold',
marginBottom: '8px'
marginBottom: '4px'
};
const defaultTextStyles = {
fontSize: '16px',
marginBottom: '16px'
marginBottom: '10px'
};
const bannerButtons = {
marginTop: '20px'
marginTop: 'auto'
};
const defaultButtonStyles: CSSProperties = {
textAlign: 'left',
Expand All @@ -82,71 +82,100 @@ export const Banner = (props: IBannerProps) => {
cursor: 'pointer'
};
const defaultTextParentStyles = {
flex: '1'
flex: '1',
maxWidth: 'calc(100% - 80px)'
};

return (
<div
className="banner"
style={{
...defaultBannerStyles,
...BannerStyle
}}
onClick={onClickView}
>
<>
<style>
{`
@media screen and (max-width: 800px) {
.titleText {
overflow: hidden;
text-overflow: ellipsis;
max-height: 2.6em;
line-height: 1.3em;
}
.banner {
height: 250px;
display: flex;
flex-direction: column;
}
}
`}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to keep our styles and our components separate. Please, at a minimum, pull this out into its own constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

</style>
<div
className="banner"
style={{
display: 'flex',
flexDirection: 'row'
...defaultBannerStyles,
...BannerStyle
}}
onClick={onClickView}
>
<div style={defaultTextParentStyles}>
<div style={{ overflowWrap: 'anywhere' }}>
<text style={{ ...defaultTitleStyles, ...titleStyle }}>
<div
style={{
display: 'flex',
flexDirection: 'row'
}}
>
<div style={defaultTextParentStyles}>
<text
className="titleText"
style={{
...defaultTitleStyles,
...titleStyle,
display: 'block'
Copy link
Contributor

Choose a reason for hiding this comment

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

display: block should go into defaultTitleStyles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}}
>
{title}
</text>
<br></br>
<text style={{ ...defaultTextStyles, ...textStyle }}>{text}</text>
</div>
<div style={bannerButtons}>
{primaryBtnLabel ? (
<button
disabled={disablePrimaryBtn}
style={
disablePrimaryBtn
? {
...defaultButtonStyles,
...primaryDisableBtnStyle
}
: { ...defaultButtonStyles, ...primaryBtnStyle }
}
onClick={onClickPrimaryBtn}
>
{primaryBtnLabel ? primaryBtnLabel : 'Button 1'}
</button>
) : null}
{secondaryBtnLabel ? (
<button
disabled={disableSecondaryBtn}
style={
disableSecondaryBtn
? {
...defaultButtonStyles,
...secondaryDisableBtnStyle
}
: { ...defaultButtonStyles, ...secondaryBtnStyle }
}
onClick={onClickSecondaryBtn}
>
{secondaryBtnLabel ? secondaryBtnLabel : 'Button 2'}
</button>
) : null}
<text
className="titleText"
style={{ ...defaultTextStyles, ...textStyle, display: 'block' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

>
{text}
</text>
</div>
{imgSrc && (
<img style={{ ...defaultImageStyles, ...imgStyle }} src={imgSrc} />
)}
</div>
<div style={bannerButtons}>
{primaryBtnLabel ? (
<button
disabled={disablePrimaryBtn}
style={
disablePrimaryBtn
? {
...defaultButtonStyles,
...primaryDisableBtnStyle
}
: { ...defaultButtonStyles, ...primaryBtnStyle }
}
onClick={onClickPrimaryBtn}
>
{primaryBtnLabel ? primaryBtnLabel : 'Button 1'}
</button>
) : null}
{secondaryBtnLabel ? (
<button
disabled={disableSecondaryBtn}
style={
disableSecondaryBtn
? {
...defaultButtonStyles,
...secondaryDisableBtnStyle
}
: { ...defaultButtonStyles, ...secondaryBtnStyle }
}
onClick={onClickSecondaryBtn}
>
{secondaryBtnLabel ? secondaryBtnLabel : 'Button 2'}
</button>
) : null}
</div>
{imgSrc && (
<img style={{ ...defaultImageStyles, ...imgStyle }} src={imgSrc} />
)}
</div>
</div>
</>
);
};
123 changes: 75 additions & 48 deletions src/components/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ export const Card = (props: ICardProps) => {
const defaultTitleStyles = {
fontSize: '18px',
fontWeight: 'bold',
marginBottom: '10px'
marginBottom: '4px'
};
const defaultTextStyles = {
fontSize: '14px',
marginBottom: '16px'
marginBottom: '10px'
};
const defaultButtonStyles: CSSProperties = {
textAlign: 'left',
Expand All @@ -87,59 +87,86 @@ export const Card = (props: ICardProps) => {
};

const cardButtons = {
marginTop: '20px',
marginTop: 'auto',
marginLeft: '5px'
};

return (
<div style={{ ...defaultCardStyles, ...cardStyle }} onClick={onClickView}>
{imgSrc && (
<img style={{ ...defaultImageStyles, ...imgStyle }} src={imgSrc} />
)}
<div style={{ ...defaultTextParentStyles }}>
<text
style={{ ...defaultTitleStyles, ...titleStyle, display: 'block' }}
>
{title}
</text>
<text style={{ ...defaultTextStyles, ...textStyle, display: 'block' }}>
{text}
</text>
</div>
<div style={cardButtons}>
{primaryBtnLabel ? (
<button
disabled={disablePrimaryBtn}
style={
disablePrimaryBtn
? {
...defaultButtonStyles,
...primaryDisableBtnStyle
}
: { ...defaultButtonStyles, ...primaryBtnStyle }
<>
<style>
{`
@media screen and (max-width: 800px) {
Copy link
Contributor

Choose a reason for hiding this comment

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

styles should be in a const

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

.titleText {
overflow: hidden;
text-overflow: ellipsis;
max-height: 2.6em;
line-height: 1.3em;
}
onClick={onClickPrimaryBtn}
>
{primaryBtnLabel ? primaryBtnLabel : 'Button 1'}
</button>
) : null}
{secondaryBtnLabel ? (
<button
disabled={disableSecondaryBtn}
style={
disableSecondaryBtn
? {
...defaultButtonStyles,
...secondaryDisableBtnStyle
}
: { ...defaultButtonStyles, ...secondaryBtnStyle }
.card {
height: 450px;
display: flex;
flex-direction: column;
}
onClick={onClickSecondaryBtn}
}
`}
</style>
<div
className="card"
style={{ ...defaultCardStyles, ...cardStyle }}
onClick={onClickView}
>
{imgSrc && (
<img style={{ ...defaultImageStyles, ...imgStyle }} src={imgSrc} />
)}
<div style={{ ...defaultTextParentStyles }}>
<text
className="titleText"
style={{ ...defaultTitleStyles, ...titleStyle, display: 'block' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

display: block again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

>
{title}
</text>
<text
className="titleText"
style={{ ...defaultTextStyles, ...textStyle, display: 'block' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

>
{secondaryBtnLabel ? secondaryBtnLabel : 'Button 2'}
</button>
) : null}
{text}
</text>
</div>
<div style={cardButtons}>
{primaryBtnLabel ? (
<button
disabled={disablePrimaryBtn}
style={
disablePrimaryBtn
? {
...defaultButtonStyles,
...primaryDisableBtnStyle
}
: { ...defaultButtonStyles, ...primaryBtnStyle }
}
onClick={onClickPrimaryBtn}
>
{primaryBtnLabel ? primaryBtnLabel : 'Button 1'}
</button>
) : null}
{secondaryBtnLabel ? (
<button
disabled={disableSecondaryBtn}
style={
disableSecondaryBtn
? {
...defaultButtonStyles,
...secondaryDisableBtnStyle
}
: { ...defaultButtonStyles, ...secondaryBtnStyle }
}
onClick={onClickSecondaryBtn}
>
{secondaryBtnLabel ? secondaryBtnLabel : 'Button 2'}
</button>
) : null}
</div>
</div>
</div>
</>
);
};
Loading