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

Add minimal prop to Callout which hides the background fill color #6952

Merged
merged 5 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions packages/core/changelog/@unreleased/pr-6952.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: feature
feature:
description: Add minimal prop to Callout which hides the background fill color
links:
- https://github.com/palantir/blueprint/pull/6952
19 changes: 15 additions & 4 deletions packages/core/src/components/callout/_callout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ $callout-padding-compact: $pt-grid-size;

.#{$ns}-callout {
@include running-typography();
background-color: rgba($gray3, 0.15);
border-radius: $pt-border-radius;
padding: $callout-padding;
position: relative;
width: 100%;

&:not(.#{$ns}-minimal) {
background-color: rgba($gray3, 0.15);
}

// CSS API support
&[class*="#{$ns}-icon-"] {
padding-left: $callout-padding + $pt-icon-size-standard + ($pt-grid-size * 0.7);
Expand Down Expand Up @@ -88,7 +91,9 @@ $callout-padding-compact: $pt-grid-size;
}

.#{$ns}-dark & {
background-color: rgba($gray3, 0.2);
&:not(.#{$ns}-minimal) {
background-color: rgba($gray3, 0.2);
}

&[class*="#{$ns}-icon-"]::before,
&.#{$ns}-callout-icon > .#{$ns}-icon:first-child {
Expand All @@ -98,9 +103,12 @@ $callout-padding-compact: $pt-grid-size;

@each $intent, $color in $pt-intent-colors {
&.#{$ns}-intent-#{$intent} {
background-color: rgba($color, 0.1);
color: map-get($pt-intent-text-colors, $intent);

&:not(.#{$ns}-minimal) {
background-color: rgba($color, 0.1);
}

@media (forced-colors: active) and (prefers-color-scheme: dark) {
border: 1px solid $pt-high-contrast-mode-border-color;
}
Expand All @@ -112,9 +120,12 @@ $callout-padding-compact: $pt-grid-size;
}

.#{$ns}-dark & {
background-color: rgba($color, 0.2);
color: map-get($pt-dark-intent-text-colors, $intent);

&:not(.#{$ns}-minimal) {
background-color: rgba($color, 0.2);
}

&[class*="#{$ns}-icon-"]::before,
> .#{$ns}-icon:first-child,
.#{$ns}-heading {
Expand Down
10 changes: 9 additions & 1 deletion packages/core/src/components/callout/callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ export interface CalloutProps extends IntentProps, Props, HTMLDivProps {
*/
intent?: Intent;

/**
* Whether the callout should have a minimal appearance with no background color fill.
*
* @default false
*/
minimal?: boolean;

/**
* String content of optional title element.
*
Expand All @@ -78,12 +85,13 @@ export class Callout extends AbstractPureComponent<CalloutProps> {
public static displayName = `${DISPLAYNAME_PREFIX}.Callout`;

public render() {
const { className, children, icon, intent, title, compact, ...htmlProps } = this.props;
const { className, children, icon, intent, title, compact, minimal = false, ...htmlProps } = this.props;
const iconElement = this.renderIcon(icon, intent);
const classes = classNames(Classes.CALLOUT, Classes.intentClass(intent), className, {
[Classes.CALLOUT_HAS_BODY_CONTENT]: !Utils.isReactNodeEmpty(children),
[Classes.CALLOUT_ICON]: iconElement != null,
[Classes.COMPACT]: compact,
[Classes.MINIMAL]: minimal,
});

return (
Expand Down
5 changes: 5 additions & 0 deletions packages/docs-app/changelog/@unreleased/pr-6952.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: feature
feature:
description: Add minimal prop to Callout which hides the background fill color
links:
- https://github.com/palantir/blueprint/pull/6952
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const CalloutExample: React.FC<DocsExampleProps> = props => {
const [showTitle, setShowTitle] = React.useState(true);
const [icon, setIcon] = React.useState<IconName>();
const [intent, setIntent] = React.useState<Intent>();
const [minimal, setMinimal] = React.useState(false);

/* eslint-disable react/jsx-key */
const children = [
Expand All @@ -48,6 +49,7 @@ export const CalloutExample: React.FC<DocsExampleProps> = props => {
<H5>Props</H5>
<Switch checked={showTitle} label="Title" onChange={handleBooleanChange(setShowTitle)} />
<Switch checked={compact} label="Compact" onChange={handleBooleanChange(setCompact)} />
<Switch checked={minimal} label="Minimal" onChange={handleBooleanChange(setMinimal)} />
<IntentSelect intent={intent} onChange={setIntent} showClearButton={true} />
<IconSelect iconName={icon} onChange={setIcon} />
<H5>Children</H5>
Expand All @@ -65,7 +67,10 @@ export const CalloutExample: React.FC<DocsExampleProps> = props => {

return (
<Example options={options} {...props}>
<Callout {...{ compact, intent, icon }} title={showTitle ? "Visually important content" : undefined}>
<Callout
{...{ compact, intent, icon, minimal }}
title={showTitle ? "Visually important content" : undefined}
>
{children}
</Callout>
</Example>
Expand Down