Skip to content
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

coreui NoteBox component #1276

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

coreui NoteBox component #1276

wants to merge 8 commits into from

Conversation

dmfalke
Copy link
Member

@dmfalke dmfalke commented Nov 15, 2024

This PR introduces a NoteBox component. It is meant to be an alternative to Banner, integrating better on content-heavy pages, like record pages.

@dmfalke dmfalke requested a review from asizemore November 15, 2024 20:30
Copy link
Member

@asizemore asizemore left a comment

Choose a reason for hiding this comment

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

Mostly just suggestions and questions. Otherwise looks really good! And it's 1000x better than what we have.

One big one - I'm not seeing the "Read more"/"Read less" button here, but I believe i should be?

Screen Shot 2024-11-20 at 5 46 27 PM

}

const baseCss = css`
border-left: 0.25em solid var(--note-box-border-color);
Copy link
Member

Choose a reason for hiding this comment

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

ive never seen this before. That's very slick


const Template: Story<Props> = function Template(props) {
return (
<UIThemeProvider
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to add the theme here? Or is it just to check that we get the correct colors regardless of theme?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was just following the same pattern as another story file (can't remember which one). I guess we could take it out, but not sure it hurts?

children: ReactNode;
}

const baseCss = css`
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps additionally a default font? I believe coreui generally uses Inter or Roboto

Copy link
Member Author

Choose a reason for hiding this comment

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

For content, I think we should use the same font as the rest of the site, but I will take a look at using one of these other fonts.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'm going to leave the font as-is.

</div>
),
},
});
Copy link
Member

Choose a reason for hiding this comment

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

A story using a different type of child (for example, an image or some other non-text element) would be helpful if time allows

Copy link
Member

Choose a reason for hiding this comment

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

or an expandable one

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I agree! I will add a couple more, soon.

: props.type === 'error'
? errorCss
: infoCss;
return <div css={finalCss}>{props.children}</div>;
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps for later, but it'd be nice to pair the icon with the NoteBox type. We picked one icon for error, warning, and info ( a looong time ago and i think it was never actually impllemented). Of course, one could pass that as part of the child, but if we want to keep coreui very opinionated then there could be a useIcon prop and if that is true. the appropriate icon for that NoteBox style appears.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed!

{warningText}
</div>
)}
{warningText && <NoteBox type="error">{warningText}</NoteBox>}
Copy link
Member

Choose a reason for hiding this comment

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

we should either change warningText to errorText or use the type='warning'. Having "warning" text in an error Notebox is confusing.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is one of those things where someone wanted the box to be red, even though it isn't strictly an error. I will change it to errorText for clarity.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@asizemore
Copy link
Member

asizemore commented Nov 20, 2024

ahh i found it.
Screen Shot 2024-11-20 at 5 49 27 PM

It's tough to understand styling when so much is populated from whatever we're given from the backend! A blessing and a curse 😆

@dmfalke
Copy link
Member Author

dmfalke commented Nov 20, 2024

Mostly just suggestions and questions. Otherwise looks really good! And it's 1000x better than what we have.

One big one - I'm not seeing the "Read more"/"Read less" button here, but I believe i should be?

Screen Shot 2024-11-20 at 5 46 27 PM

I fixed a bug related to this. Maybe on this branch? Anyway, I'll take a look.

@dmfalke
Copy link
Member Author

dmfalke commented Nov 21, 2024

Mostly just suggestions and questions. Otherwise looks really good! And it's 1000x better than what we have.

One big one - I'm not seeing the "Read more"/"Read less" button here, but I believe i should be?

Screen Shot 2024-11-20 at 5 46 27 PM

I fixed a bug related to this. Maybe on this branch? Anyway, I'll take a look.

Oh, I know what's going on here. This specific case is using a <details> element. It is likely closed by default, which means the overflow detection isn't triggered. This is actually kind of what we want, otherwise there would be two methods to collapse the content.

Generally, I prefer the <details> method, but I added the other one for an ortho use case. I probably should have argued my case 🙂

@asizemore
Copy link
Member

Ahh okay. Thanks @dmfalke !

Then I think all the rest of my comments are suggestions 👍

@dmfalke
Copy link
Member Author

dmfalke commented Nov 22, 2024

While testing this PR, I noticed a bug that was introduced by #1270:

The persistence of record page table state was also moved to wdk-client. There is at least one place that uses the old updateTableState action, which needs to be updated to use the new action. Additionally, the logic that handles scrolling to the selected table row also needs to be moved to RecordTableSection.

I will make a new issue for this.

A part of this involved increasing padding and border-width to
compensate for the additional space needed for the icon.
@dmfalke
Copy link
Member Author

dmfalke commented Nov 22, 2024

I've added icon support, and made some additional stories to highlight the option. I also modified the padding and border width to compensate for the additional space needed for the icon.

Copy link
Member

@asizemore asizemore left a comment

Choose a reason for hiding this comment

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

Screen Shot 2024-11-26 at 8 03 51 AM

I was hoping for a good way to align the icon with the text. First i tried the flex + align-items-center route, but that only worked until the text was multiple lines. Next I tried the less elegant way of just adding a negative top margin to the icon. That worked, but requires all of the icons to be the same size. I believe that to be true, but am not 100% certain. What do you think?

position: absolute;
left: 0.5em;
font-size: 1.5em;
`;
Copy link
Member

Choose a reason for hiding this comment

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

What do you think of adding color: var(--note-box-border-color); ?
I tried it out and thought it looked pretty good!

border-radius: 0.25em;
padding: 0.5em 1em;
padding: 1em 3em;
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: have padding change based on showIcon.

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

Successfully merging this pull request may close these issues.

2 participants