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

feat: add default variant to Alert and Badge #5456

Merged
merged 1 commit into from
Aug 9, 2021

Conversation

davidjb
Copy link
Contributor

@davidjb davidjb commented Oct 1, 2020

This sets a default variant of "primary" for Alert and Badge, allowing them to be used without having to set a variant. Bootstrap's docs on Alerts/Badges require the use of a contextual class (https://getbootstrap.com/docs/4.5/components/alerts/) in order to have proper styling.

This aligns Alert and Badge variant functionality with that of Button and Navbar, where default variants are provided and can be used like <Button>Hello</Button>.

This could be viewed as a breaking change (e.g. for someone using Alert without a variant as it now adds one). However, it could be viewed as a feature as it is adding & declaring functionality in the public API where behaviour wasn't previously explicitly defined in examples or docs.

src/Button.tsx Outdated Show resolved Hide resolved
Copy link
Member

@jquense jquense left a comment

Choose a reason for hiding this comment

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

thoughts folks? I think this is probably reasonable consistency change, however i do think it'd have to be considered a breaking change so maybe (if accepted) should go in the v5 branch instead?

@davidjb davidjb changed the title feat: add default variant Alert/Badge, cleanup Button feat: add default variant to Alert/Badge Oct 1, 2020
davidjb added a commit to davidjb/react-bootstrap that referenced this pull request Oct 1, 2020
This bugfix aligns the `<button>` variant class implementation with
Alert/Badge/Navbar -- only outputing a `prefix-variant` formatted class
when a variant is specified and avoiding the situation of outputting
`.btn-null` or `.btn-` when the variant is null or an empty string
respectively

Split from react-bootstrap#5456
@davidjb davidjb changed the title feat: add default variant to Alert/Badge feat: add default variant to Alert and Badge Oct 1, 2020
jquense pushed a commit that referenced this pull request Oct 1, 2020
This bugfix aligns the `<button>` variant class implementation with
Alert/Badge/Navbar -- only outputing a `prefix-variant` formatted class
when a variant is specified and avoiding the situation of outputting
`.btn-null` or `.btn-` when the variant is null or an empty string
respectively

Split from #5456
@kyletsang
Copy link
Member

Sounds good to me. Let's push it to v5

@kdgyimah
Copy link

kdgyimah commented Aug 6, 2021

thoughts folks? I think this is probably reasonable consistency change, however i do think it'd have to be considered a breaking change so maybe (if accepted) should go in the v5 branch instead?

I would agree on that as well.
I usually set up my Alerts to render primary as the default variant anyways 😄.

@kyletsang
Copy link
Member

@davidjb, sorry for the delay on this. Can you rebase this and change variant in Badge to bg? Things have changed in v2. We should be good to merge after this.

Thanks!

This sets a default variant and bg of "primary" for Alert and Badge
respectively, allowing them to be used without having to set a variant
or bg.

Bootstrap's docs on Alerts require the use of a contextual class
(https://getbootstrap.com/docs/5.1/components/alerts/) in order to have
proper styling.

This aligns Alert and Badge variant functionality with that of Button
and Navbar.

This could be viewed as a breaking change (e.g. for someone using Alert
without a variant [as it now adds one] or someone relying on Button's
`.btn-null` [if the variant was null]).  However, I'm inclined to view
this as a feature as it is adding & declaring functionality in the
public API where behaviour wasn't previously explicitly defined in
examples or docs.
@davidjb
Copy link
Contributor Author

davidjb commented Aug 9, 2021

@kyletsang Done! That should be it - rebased, updated the Badge and its tests, plus updated commit message.

In v5.x, the Badge is particularly important to have a default bg because its text is white, making it unreadable on a standard background. At least in 4.x it was black text by default.

@kyletsang kyletsang merged commit 8f76539 into react-bootstrap:master Aug 9, 2021
@kyletsang
Copy link
Member

Thanks!

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.

None yet

4 participants