-
Notifications
You must be signed in to change notification settings - Fork 3
Add external links page section #141
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
Conversation
1e0ce42
to
ae6e492
Compare
Hey @epapbak thanks for getting this done!
|
return ( | ||
<Flex direction={{default: 'column'}} flex={{default: 'flex_3'}} | ||
justifyContent={{default: 'justifyContentSpaceBetween'}} | ||
style={{border: '1px solid #D2D2D2', padding: '2%'}}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh I find inline styles pretty ugly. That's a preference obviously - but I think code is much cleaner, if you use CSS files for adding the styles, and use classNames for the selectors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer one CSS file per page, but if you have very little custom CSS (which should be your goal) we can keep the whole CSS in a single file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a very general note I'd like to add, as I agree with @KKoukiou about the goal of as little custom CSS as possible...
One thing that I have learned about working with designers is that they will usually happily defer to Patternfly's established patterns.
When I find myself in a situation where I would need a lot of custom CSS to match a design, I'll usually try to figure out the 'standard' way to do it in Patternfly and then go back to the designer and propose we use their pattern. That almost always leads to everyone being happy, and I don't have to write any CSS.
Here, the custom CSS is actually a red flag to me... It might be totally necessary, I don't know, but I'm eager to look at the designs to confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to use different layouts offered by Patternfly, but the end result was always slightly different from what I expected.
For example, aligning the "Build an image ->" link with the other links was pretty much impossible without using Flex
layout with justifyContent={{default: 'justifyContentSpaceBetween'}}
and alignSelf={{default: "alignSelfStretch"}}
on each child. But I'm a beginner with this framework, so there might be something I missed while trying it out...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the layout, I wonder if you might have more luck using a grid?
https://www.patternfly.org/v4/layouts/grid#with-gutters
You should be able to specify a span of 4 for the first card and 8 for the second card.
You might still run into an issue here where it doesn't behave well at different viewport widths, though... To be honest I'm not 100% sure what the best solution is but I would look into the Patternfly layouts... the grid, the level, or the split could all be potential options.
https://www.patternfly.org/v4/layouts/level
https://www.patternfly.org/v4/layouts/split
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did spend an entire afternoon trying to do it with the Grid and Split layouts. Didn't try Level though. I'll give it a go when I have some time, see if I can make it work without additional styling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, yes alignment can be tricky. There's a reason centering a div is a meme... 😭 😉
If I can find some time this afternoon I'll try a few things out, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work reasonably well:
<Grid hasGutter>
<GridItem md={4} sm={12}>
<InternalLinksCard />
</GridItem>
<GridItem md={8} sm={12}>
<ExternalLinksCard />
</GridItem>
</Grid>
Sure - please share the expected view (mockup) and some instructions on how to build this ideally, so that I can try this out. |
I've send you the sketch file. You can run the project after "npm install" either through "npm run start:dev" or "npm run build && npm start" for the production build. |
|
c690eac
to
3b8167b
Compare
return ( | ||
<Flex direction={{default: 'column'}} flex={{default: 'flex_3'}} | ||
justifyContent={{default: 'justifyContentSpaceBetween'}} | ||
style={{border: '1px solid #D2D2D2', padding: '2%'}}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it seems to me that this styling is really just re-implementing a card. What if you used a card from Patternfly here instead?
https://www.patternfly.org/v4/components/card/
Now, the card does have a shadow and your design does not. There is a 95% chance that this is fine. This is where if you tell your designer "Hey, you know the PF card has a shadow by default!" there is a good chance they will say "Oh, okay, let's go with that!".
If they say "No, no shadow here for {REASONS}", then you can use CSS (for the card!) to remove the border. The PF documentation has the specific CSS selectors:
https://www.patternfly.org/v4/components/card/#css-variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, regarding the shadow, all you need to do is pass in the isFlat
prop and it will look exactly like the designs! https://www.patternfly.org/v4/components/card#modifiers
|
||
<> | ||
<FlexItem key={`provider_card_${name}`} | ||
style={{borderRight: index != providerInfos.length - 1 ? '1px solid #979797' : 'null'}}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another good example of where you should start questioning yourself when you start writing custom styles... which you should avoid as much as possible! 😉 In this case, you're re-implementing a divider... check it out here:
https://www.patternfly.org/v4/components/divider/#vertical-in-flex-layout
My advice is that anytime you start writing custom styles, ask yourself, is there an existing Patternfly component that does this? 99% of the time, there is an existing Patternfly pattern that the designers will defer to. That's their gold standard and what they will refer to themselves to answer these kinds of questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also probably use a <Card>
here as well, just pass the isPlain
prop in to remove the border.
<Flex direction={{default: 'column'}} flex={{default: 'flex_1'}} | ||
justifyContent={{default: 'justifyContentSpaceBetween'}} | ||
alignSelf={{default: "alignSelfStretch"}} | ||
style={{border: '1px solid #D2D2D2', padding: '2%'}}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I think you ought to also use the Card component:
https://www.patternfly.org/v4/components/card
const providerInfos = [ | ||
{ | ||
name: 'aws', | ||
text: 'Launch in AWS ->', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an icon in Patternfly for the arrow you might be able to use, search for fa-arrow-right
:
https://www.patternfly.org/v4/guidelines/icons/#all-icons
I’ll be on holiday for the next two weeks so this is the last feedback I have for a while! I was actually able to make a lot of progress on the layout. I recommend using <PageSection variant={PageSectionVariants.light}>
<Grid hasGutter>
<GridItem md={4} sm={12}>
<InternalLinksCard />
</GridItem>
<GridItem md={8} sm={12}>
<ExternalLinksCard />
</GridItem>
</Grid>
</PageSection> For the external links card, getting the icons to work well is a bit trickier. I settled on taking this approach, using const loadImage = (name: Provider) => {
switch (name) {
case Provider.aws:
return aws_logo;
case Provider.azure:
return azure_logo;
case Provider.google:
return google_logo;
}
};
const displayText = (name: Provider) => {
switch (name) {
case Provider.aws:
return 'Launch in AWS';
case Provider.azure:
return 'Launch in Azure';
case Provider.google:
return 'Launch in Google Cloud';
}
};
enum Provider {
'aws',
'azure',
'google'
}
type ProviderCardProps = {
provider: Provider;
}
const ProviderCard = ({ provider }: ProviderCardProps) => {
return (
<Stack>
<StackItem>
<Bullseye>
<img style={{ height: 100, width: 100 }} src={loadImage(provider)} />
</Bullseye>
</StackItem>
<StackItem>
<Bullseye>
<Button variant="link" isLarge>
{displayText(provider)} <ArrowRightIcon />
</Button>
</Bullseye>
</StackItem>
</Stack>
)
}
const ExternalLinksCard: React.FunctionComponent = () => {
return (
<Card isLarge isFlat>
<CardTitle>
<Stack>
<StackItem>
<img
src={redhat_logo}
style={{
height: '2vw',
}}/>
</StackItem>
<StackItem>
<p>Get the latest Red Hat Enterprise Linux certified image for cloud deployment</p>
</StackItem>
</Stack>
</CardTitle>
<CardBody>
<p>Launch the latest RHEL certified cloud image through available cloud service provider marketplaces.</p>
<br/>
<Flex justifyContent={{ default: 'justifyContentCenter'}}>
<FlexItem>
<ProviderCard provider={Provider.aws} />
</FlexItem>
<FlexItem>
<ProviderCard provider={Provider.google} />
</FlexItem>
<FlexItem>
<ProviderCard provider={Provider.azure} />
</FlexItem>
</Flex>
</CardBody>
</Card>
);
}; For the internal links card, I took this approach: const InternalLinksCard: React.FunctionComponent = () => {
return (
<Card isFlat isFullHeight isLarge>
<CardTitle>
<Stack>
<StackItem>
<img
src={redhat_logo}
style={{
height: '2vw',
}}/>
</StackItem>
<StackItem>
<p>Build your own RHEL cloud image</p>
</StackItem>
</Stack>
</CardTitle>
<CardBody>With Red Hat's Image Builder, you can create customizable and repeatable operating system images and server images.</CardBody>
<CardFooter>
<Button variant="link" isLarge>
Build an image <ArrowRightIcon />
</Button>
</CardFooter>
</Card>
);
}; There are still a few small things to do here and there. You’ll need to remove the padding on the left from the “Build an image →” link. And I have not yet added I actually think the dividers are going to be quite difficult. How does it behave at small viewports? Should the icons stack vertically? How does the transition from horizontal to vertical occur? I feel like what I have now works pretty well. Maybe you can ask the designer if the We actually have a very similar pattern in the Image Builder Wizard, and we don’t use dividers for the cloud icons. So that is an established pattern you can point to, for consistency’s sake. I think the code snippets above should be enough to get the idea but you can check out my branch here as well, apologies for the mess on the code formatting and commits 😉: https://github.com/lucasgarfield/cloud-image-directory-frontend/tree/external-links |
@lucasgarfield I really like that look! This is way more mobile friendly then the rest of the page. |
next level code reviewing 😮 !! |
3b8167b
to
47f0278
Compare
Thanks @epapbak, glad you like it! 😀 Let me know when it's ready for a second look, and don't hesitate to ping me if you get stuck on something. |
@epapbak Just a quick status check. Is this ready for a final review or do you need more time? |
It is ready for review, yes :)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks for getting this done!
@lucasgarfield @KKoukiou anything left that needs changing?
Otherwise I'd vote for creating follow up issues and getting this in.
Yep, ever growing pull requests (plus my messed up availability) might block some other work, so I'd prefer follow-up issues too. |
LGTM! I agree that any issues that arise can be dealt with in follow-up PRs. Great work @epapbak. 😁 |
Implements issue #95.
TODO: