Skip to content

add OpenShift LogSnippet #105

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 31 commits into from
Feb 22, 2024
Merged

add OpenShift LogSnippet #105

merged 31 commits into from
Feb 22, 2024

Conversation

InsaneZein
Copy link
Collaborator

@InsaneZein InsaneZein commented Feb 8, 2024

image

closes #99

borderLeft: '2px solid var(--pf-v5-global--danger-color--100)',
display: 'flex',
flexDirection: 'column',
marginLeft: '6px',
Copy link
Contributor

Choose a reason for hiding this comment

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

Ther are PF CSS variables for margins/paddings we should be using

const useStyles = createUseStyles({
logSnippet: {
borderLeft: '2px solid var(--pf-v5-global--danger-color--100)',
display: 'flex',
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a PF layout we should be able to use rather than hardcoding layouts into the CSS. https://www.patternfly.org/layouts/flex

import { createUseStyles } from 'react-jss'

const useStyles = createUseStyles({
logSnippet: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We usually use clsx with this. Is there a reason we aren't here? I think we should use a layout instead of the div and p below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought clsx was just for conditional rendering

},
});

interface LogSnippetProps {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be exported.

const classes = useStyles();

return (
<div className={classes.logSnippet}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a PF layout you can use instead of these div and paragraphs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've replaced the div with the flex layout. I'm not sure what to do about the paragraph. Is there something you have in mind?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dlabaj
Copy link
Collaborator

dlabaj commented Feb 8, 2024

@InsaneZein Looks like linting is failing.

subsection: Component groups
# Sidenav secondary level section
# should be the same for all markdown files
id: LogSnippet
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
id: LogSnippet
id: Log snippet

url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;

return <>
<LogSnippet message='A log snippet' logSnippet={code} />
Copy link
Collaborator

@fhlavac fhlavac Feb 12, 2024

Choose a reason for hiding this comment

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

We could maybe adjust the label to make it more explicit what is its purpose

Suggested change
<LogSnippet message='A log snippet' logSnippet={code} />
<LogSnippet message='Failure - check logs for details' logSnippet={code} />


const useStyles = createUseStyles({
logSnippet: {
borderLeft: '2px solid var(--pf-v5-global--danger-color--100)',
Copy link
Collaborator

Choose a reason for hiding this comment

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

The red border should be probably optional or at least overridable with custom class. We may also need a different variant than danger

Copy link
Collaborator

Choose a reason for hiding this comment

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

@nicolethoen please, what do you think about the border vs PF habits? Do we want to have it visible by default with an option to hide and select color variant? Or maybe do not show it and if OpenShift wants it, they can pass a custom className? Thank you

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a few ways it could be done.
An additional prop could be used - either a flag like isBorderLeft, or an enum like borderLeftVariant='red|<other options>.
we could even expose a customBorderLeftColor which could override this style if we want red to be the default?

Copy link
Collaborator

@fhlavac fhlavac Feb 14, 2024

Choose a reason for hiding this comment

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

I would probably vote for borderLeftVariant with colors and "hidden" option. Thoughts? @InsaneZein @nicolethoen

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I'm good with that. I'll get to it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@nicolethoen is there a subset of acceptable colors? I just went ahead and added 'red' | 'green' | 'blue' | 'cyan' | 'gold' | 'orange' | 'purple'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I talked with @fhlavac we're thinking of just passing in "danger", "success", "info", "warning", or "hidden" so the variants would be --pf-v5-global--danger-color--100 --pf-v5-global--success-color--100 --pf-v5-global--info-color--100 --pf-v5-global--warning-color--100

export interface LogSnippetProps {
/** log snippet or code you would like to display */
logSnippet?: string;
/** message to appear above the log snippet */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/** message to appear above the log snippet */
/** Message to appear above the log snippet */

});

export interface LogSnippetProps {
/** log snippet or code you would like to display */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/** log snippet or code you would like to display */
/** Log snippet or code to be displayed */

borderLeft: '2px solid var(--pf-v5-global--danger-color--100)',
marginLeft: 'var(--pf-v5-global--spacer--sm)',
padding: 'var(--pf-v5-global--spacer--sm) 0 var(--pf-v5-global--spacer--sm) var(--pf-v5-global--spacer--sm)',
backgroundColor: 'white'
Copy link
Collaborator

Choose a reason for hiding this comment

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

we may want to use PF variable as well

backgroundColor: 'white'
},
statusMessage: {
marginBottom: '10px',
Copy link
Collaborator

Choose a reason for hiding this comment

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

could be replaced by PF variable depending on UX suggestions

@fhlavac
Copy link
Collaborator

fhlavac commented Feb 12, 2024

@InsaneZein looks good, just some styling/cleanup notes. Thank you 🎉

/** Log snippet or code to be displayed */
logSnippet?: string;
/** Message to appear above the log snippet */
message: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thinking if it wouldn't be better to make the message a ReactNode to be easier customizable. If string is passed, we can wrap it inside Text as we do now

const classes = useStyles();

return (
<Flex direction={{ default: 'column' }} className={classes.logSnippet}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

@InsaneZein what do you think about extending FlexProps in the LogSnippetProps to make this more customizable?


const useStyles = createUseStyles({
logSnippet: {
borderLeft: '2px solid var(--pf-v5-global--danger-color--100)',
Copy link
Collaborator

Choose a reason for hiding this comment

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

also, we could use the PF variable for the border width - --pf-v5-global--BorderWidth--md

@patternfly-build
Copy link

patternfly-build commented Feb 20, 2024

@dlabaj
Copy link
Collaborator

dlabaj commented Feb 20, 2024

@InsaneZein If you rebase this with main it should now pass.

Copy link
Collaborator

@dlabaj dlabaj left a comment

Choose a reason for hiding this comment

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

LGTM

logSnippet: {
marginLeft: 'var(--pf-v5-global--spacer--sm)',
padding: 'var(--pf-v5-global--spacer--sm) 0 var(--pf-v5-global--spacer--sm) var(--pf-v5-global--spacer--sm)',
backgroundColor: 'var(--pf-v5-global--palette--black-100)'
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 advocate that we use a more meaningful variable here: maybe: --pf-v5-global--BackgroundColor--200

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@jessiehuff jessiehuff left a comment

Choose a reason for hiding this comment

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

LGTM!

@fhlavac
Copy link
Collaborator

fhlavac commented Feb 22, 2024

@InsaneZein one last thing - we seem to be missing feat(xx): prefix in at least one commit message to trigger the release. Can you please add it?

@nicolethoen nicolethoen merged commit e230962 into main Feb 22, 2024
Copy link

🎉 This PR is included in version 5.1.0-prerelease.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate OpenShift LogSnippet to component groups
6 participants