Skip to content
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
11 changes: 11 additions & 0 deletions .changeset/pf-banner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@patternfly/elements": minor
---

✨ Added `<pf-banner>`

```html
<pf-banner variant="info" icon="info" sticky>
Important information.
</pf-banner>
```
1 change: 1 addition & 0 deletions elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"./pf-avatar/pf-avatar.js": "./pf-avatar/pf-avatar.js",
"./pf-badge/BaseBadge.js": "./pf-badge/BaseBadge.js",
"./pf-badge/pf-badge.js": "./pf-badge/pf-badge.js",
"./pf-banner/pf-banner.js": "./pf-banner/pf-banner.js",
"./pf-button/BaseButton.js": "./pf-button/BaseButton.js",
"./pf-button/pf-button.js": "./pf-button/pf-button.js",
"./pf-card/BaseCard.js": "./pf-card/BaseCard.js",
Expand Down
60 changes: 60 additions & 0 deletions elements/pf-banner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Patternfly Elements Banner
A banner is a 1-line, full color, full width container that can be used to communicate short snippets of information to users. Banners are un-intrusive and non-dismissible.

Read more about Button in the [PatternFly Elements Banner documentation](https://patternflyelements.org/components/banner)

## Installation
Load `<pf-banner>` via CDN:

```html
<script src="https://jspm.dev/@patternfly/elements/pf-banner/pf-banner.js"></script>
```
Or, if you are using [NPM](https://npm.im/), install it

```bash
npm install @patternfly/elements
```
Then once installed, import it to your application:

```js
import '@patternfly/elements/pf-banner/pf-banner.js';
```


## Usage

```html
<pf-banner>
Default banner
</pf-banner>
```


## Attributes

### Variant
Banners have five different variants. The available variants are `default`, `info`, `success`, `danger`, and `warning`.

```html
<pf-banner variant="info">
Info banner
</pf-banner>
```

### Icon
Banners can have an icon attribute for a shorthand to Patternfly Icons. To see available icons, visit the [Patternfly Elements Icons documentation](https://patternflyelements.com/components/icons/).

```html
<pf-banner variant="info" icon="info">
Info banner
</pf-banner>
```

### Sticky
Banners can be sticky, so they stick to the top of the parent.

```html
<pf-banner sticky>
Sticky banner
</pf-banner>
```
15 changes: 15 additions & 0 deletions elements/pf-banner/demo/pf-banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<pf-banner>Default Banner</pf-banner>
<pf-banner variant="info">Blue Banner</pf-banner>
<pf-banner variant="danger">Red Banner</pf-banner>
<pf-banner variant="success">Green Banner</pf-banner>
<pf-banner variant="warning">Gold Banner</pf-banner>

<script type="module">
import '@patternfly/elements/pf-banner/pf-banner.js';
</script>

<style>
pf-banner + pf-banner {
margin-block-start: 1rem;
}
</style>
39 changes: 39 additions & 0 deletions elements/pf-banner/demo/status-banners.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<pf-banner>
<svg slot="icon"
viewBox="0 0 896 1024"
aria-hidden="true"
role="img">
<path d="M448,0 C465.333333,0 480.333333,6.33333333 493,19 C505.666667,31.6666667 512,46.6666667 512,64 L512,106 L514.23,106.45 C587.89,121.39 648.48,157.24 696,214 C744,271.333333 768,338.666667 768,416 C768,500 780,568.666667 804,622 C818.666667,652.666667 841.333333,684 872,716 C873.773676,718.829136 875.780658,721.505113 878,724 C890,737.333333 896,752.333333 896,769 C896,785.666667 890,800.333333 878,813 C866,825.666667 850.666667,832 832,832 L63.3,832 C44.9533333,831.84 29.8533333,825.506667 18,813 C6,800.333333 0,785.666667 0,769 C0,752.333333 6,737.333333 18,724 L24,716 L25.06,714.9 C55.1933333,683.28 77.5066667,652.313333 92,622 C116,568.666667 128,500 128,416 C128,338.666667 152,271.333333 200,214 C248,156.666667 309.333333,120.666667 384,106 L384,63.31 C384.166667,46.27 390.5,31.5 403,19 C415.666667,6.33333333 430.666667,0 448,0 Z M576,896 L576,897.08 C575.74,932.6 563.073333,962.573333 538,987 C512.666667,1011.66667 482.666667,1024 448,1024 C413.333333,1024 383.333333,1011.66667 358,987 C332.666667,962.333333 320,932 320,896 L576,896 Z"></path>
</svg>
Default Banner
</pf-banner>

<pf-banner variant="info">
<pf-icon icon="info-circle" slot="icon"></pf-icon>
Info Banner
</pf-banner>

<pf-banner variant="danger">
<pf-icon icon="exclamation-circle" slot="icon"></pf-icon>
Danger Banner
</pf-banner>

<pf-banner variant="success">
<pf-icon icon="check-circle" slot="icon"></pf-icon>
Success Banner
</pf-banner>

<pf-banner variant="warning">
<pf-icon icon="exclamation-triangle" slot="icon"></pf-icon>
Warning Banner
</pf-banner>

<script type="module">
import '@patternfly/elements/pf-banner/pf-banner.js';
</script>

<style>
pf-banner + pf-banner {
margin-block-start: 1rem;
}
</style>
55 changes: 55 additions & 0 deletions elements/pf-banner/demo/sticky.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<pf-banner sticky>I stick to the top</pf-banner>
<header>
<h2 class="entry-title page--title">The Open Source Definition</h2>
<a href="https://opensource.org/osd/">https://opensource.org/osd/</a>
</header>

<h3>Introduction</h3>
<p>Open source doesn’t just mean access to the source code. The distribution terms of open-source software must comply with the following criteria:</p>

<h4>1. Free Redistribution</h4>
<p>The license shall not restrict any party from selling or giving away the software as a component of an aggregate software distribution containing programs from several different sources. The license shall not require a royalty or other fee for such sale.</p>


<h4>2. Source Code</h4>
<p>The program must include source code, and must allow distribution in source code as well as compiled form. Where some form of a product is not distributed with source code, there must be a well-publicized means of obtaining the source code for no more than a reasonable reproduction cost, preferably downloading via the Internet without charge. The source code must be the preferred form in which a programmer would modify the program. Deliberately obfuscated source code is not allowed. Intermediate forms such as the output of a preprocessor or translator are not allowed.</p>


<h4>3. Derived Works</h4>
<p>The license must allow modifications and derived works, and must allow them to be distributed under the same terms as the license of the original software.</p>


<h4>4. Integrity of The Author’s Source Code</h4>
<p>The license may restrict source-code from being distributed in modified form <em>only</em> if the license allows the distribution of “patch files” with the source code for the purpose of modifying the program at build time. The license must explicitly permit distribution of software built from modified source code. The license may require derived works to carry a different name or version number from the original software.</p>


<h4>5. No Discrimination Against Persons or Groups</h4>
<p>The license must not discriminate against any person or group of persons.</p>


<h4>6. No Discrimination Against Fields of Endeavor</h4>
<p>The license must not restrict anyone from making use of the program in a specific field of endeavor. For example, it may not restrict the program from being used in a business, or from being used for genetic research.</p>


<h4>7. Distribution of License</h4>
<p>The rights attached to the program must apply to all to whom the program is redistributed without the need for execution of an additional license by those parties.</p>


<h4>8. License Must Not Be Specific to a Product</h4>
<p>The rights attached to the program must not depend on the program’s being part of a particular software distribution. If the program is extracted from that distribution and used or distributed within the terms of the program’s license, all parties to whom the program is redistributed should have the same rights as those that are granted in conjunction with the original software distribution.</p>


<h4>9. License Must Not Restrict Other Software</h4>
<p>The license must not place restrictions on other software that is distributed along with the licensed software. For example, the license must not insist that all other programs distributed on the same medium must be open-source software.</p>


<h4>10. License Must Be Technology-Neutral</h4>
<p>No provision of the license may be predicated on any individual technology or style of interface.</p>

<hr>
<p>The Open Source Definition was originally derived from the <a href="https://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a> (DFSG).</p>
<p><em>Version 1.9, last modified, 2007-03-22</em></p>
<p><em>Here’s the historical “<a href="https://opensource.org/definition-annotated/">Annotated OSD</a>” from the early 2000’s. </em>
<script type="module">
import '@patternfly/elements/pf-banner/pf-banner.js';
</script>
59 changes: 59 additions & 0 deletions elements/pf-banner/docs/pf-banner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% renderOverview %}
<pf-banner>Default</pf-banner>
{% endrenderOverview %}

{% band header="Usage" %}
{% htmlexample %}
<pf-banner>Default</pf-banner>
{% endhtmlexample %}


### With a variant
Available variants are: default, info, danger, success, warning

{% htmlexample %}
<pf-banner variant="default">Default</pf-banner>
<pf-banner variant="info">Info</pf-banner>
<pf-banner variant="danger">Danger</pf-banner>
<pf-banner variant="success">Success</pf-banner>
<pf-banner variant="warning">Warning</pf-banner>
{% endhtmlexample %}


### Sticky
Banners can be set to stick to the top of their container by adding the `sticky` attribute.

{% htmlexample %}
<pf-banner sticky>Sticky</pf-banner>
{% endhtmlexample %}


### With an icon
You can add a icon by using the shorthand icon attribute

{% htmlexample %}
<pf-banner icon="info">Info</pf-banner>
{% endhtmlexample %}

Or you can use the icon slot and slot in a `svg` or `pf-icon` element

{% htmlexample %}
<pf-banner>
<pf-icon slot="icon" icon="info-circle"></pf-icon>
Info
</pf-banner>
{% endhtmlexample %}

{% endband %}

{% renderSlots %}{% endrenderSlots %}

{% renderAttributes %}{% endrenderAttributes %}

{% renderMethods %}{% endrenderMethods %}

{% renderEvents %}{% endrenderEvents %}

{% renderCssCustomProperties %}{% endrenderCssCustomProperties %}

{% renderCssParts %}{% endrenderCssParts %}
Binary file added elements/pf-banner/docs/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions elements/pf-banner/pf-banner.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
:host {
display: block;
--pf-c-banner--PaddingTop: var(--pf-global--spacer--xs, 0.25rem);
--pf-c-banner--PaddingRight: var(--pf-global--spacer--md, 1rem);
--pf-c-banner--md--PaddingRight: var(--pf-global--spacer--lg, 1.5rem);
--pf-c-banner--PaddingBottom: var(--pf-global--spacer--xs, 0.25rem);
--pf-c-banner--PaddingLeft: var(--pf-global--spacer--md, 1rem);
--pf-c-banner--md--PaddingLeft: var(--pf-global--spacer--lg, 1.5rem);
--pf-c-banner--FontSize: var(--pf-global--FontSize--sm, 0.875rem);
--pf-c-banner--Color: var(--pf-global--Color--100, #151515);
--pf-c-banner--BackgroundColor: var(--pf-global--BackgroundColor--dark-400, #4f5255);
--pf-c-banner--link--Color: var(--pf-c-banner--Color);
--pf-c-banner--link--TextDecoration: underline;
--pf-c-banner--link--hover--Color: var(--pf-c-banner--Color);
--pf-c-banner--link--hover--FontWeight: var(--pf-global--FontWeight--semi-bold, 700);
--pf-c-banner--link--disabled--Color: var(--pf-c-banner--Color);
--pf-c-banner--link--disabled--TextDecoration: none;
--pf-c-banner--m-info--BackgroundColor: var(--pf-global--palette--blue-200, #73bcf7);
--pf-c-banner--m-danger--BackgroundColor: var(--pf-global--danger-color--100, #c9190b);
--pf-c-banner--m-success--BackgroundColor: var(--pf-global--success-color--100, #3e8635);
--pf-c-banner--m-warning--BackgroundColor: var(--pf-global--warning-color--100, #f0ab00);
--pf-c-banner--m-sticky--ZIndex: var(--pf-global--ZIndex--md, 300);
--pf-c-banner--m-sticky--BoxShadow: var(--pf-global--BoxShadow--md-bottom);
}

#container,
#container.default {
color: var(--pf-global--Color--100, var(--pf-global--Color--light-100, #ffffff));
overflow: hidden;
text-overflow: ellipsis;
padding:
var(--pf-c-banner--PaddingTop, var(--pf-global--spacer--xs, 0.25rem))
var(--pf-c-banner--PaddingRight, var(--pf-global--spacer--md, 1rem))
var(--pf-c-banner--PaddingBottom, var(--pf-global--spacer--xs, 0.25rem))
var(--pf-c-banner--PaddingLeft, var(--pf-global--spacer--md, 1rem));
font-size: var(--pf-c-banner--FontSize, var(--pf-global--FontSize--sm, 0.875rem));
color: var(--pf-global--Color--100, var(--pf-global--Color--light-100, #ffffff));
white-space: nowrap;
background-color: var(--pf-c-banner--BackgroundColor, var(--pf-global--BackgroundColor--dark-400, #4f5255));

--pf-icon--size: 1em;
}

#container.info {
color: var(--pf-global--Color--100, var(--pf-global--Color--dark-100, #151515));
--pf-c-banner--BackgroundColor: var(--pf-c-banner--m-info--BackgroundColor, var(--pf-global--palette--blue-200, #73bcf7));
}

#container.danger {
--pf-c-banner--BackgroundColor: var(--pf-c-banner--m-danger--BackgroundColor, var(--pf-global--danger-color--100, #c9190b));
}

#container.success {
--pf-c-banner--BackgroundColor: var(--pf-c-banner--m-success--BackgroundColor, var(--pf-global--success-color--100, #3e8635));
}

#container.warning {
color: var(--pf-global--Color--100, var(--pf-global--Color--dark-100, #151515));
--pf-c-banner--BackgroundColor: var(--pf-c-banner--m-warning--BackgroundColor, var(--pf-global--warning-color--100, #f0ab00));
}

#container.hasIcon {
display: var(--pf-l-flex--Display, flex);
flex-wrap: var(--pf-l-flex--FlexWrap, wrap);
align-items: var(--pf-l-flex--AlignItems, baseline);
gap: var(--pf-l-flex--spacer, var(--pf-l-flex--spacer--sm, var(--pf-global--spacer--sm, 0.5rem)));
}

:host([sticky]) {
position: sticky;
top: 0;
z-index: var(--pf-c-banner--m-sticky--ZIndex, var(--pf-global--ZIndex--md, 300));
box-shadow:
var(--pf-c-banner--m-sticky--BoxShadow,
var(--pf-global--BoxShadow--md-bottom, 0 0.5rem 0.5rem -0.375rem rgba(3, 3, 3, 0.18)));
}

pf-icon,
::slotted(pf-icon),
::slotted(svg) {
position: relative;
inset-block-start: 0.125em;
}

::slotted(svg) {
height: 1em;
width: 1em;
fill: currentcolor;
}

@media (min-width: 768px) {
#container {
--pf-c-banner--PaddingRight: var(--pf-c-banner--md--PaddingRight, var(--pf-global--spacer--lg, 1.5rem));
--pf-c-banner--PaddingLeft: var(--pf-c-banner--md--PaddingLeft, var(--pf-global--spacer--lg, 1.5rem));
}
}
Loading