Skip to content

Commit

Permalink
Merge pull request #28 from opf/bump/upstream
Browse files Browse the repository at this point in the history
Update upstream primer/view_components repository
  • Loading branch information
HDinger authored Sep 14, 2023
2 parents 1970df3 + cd88ba8 commit 2a5c198
Show file tree
Hide file tree
Showing 28 changed files with 351 additions and 136 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-balloons-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@openproject/primer-view-components": patch
---

[Bug] Don't fill in the spinner circle svg path
7 changes: 7 additions & 0 deletions .changeset/cool-items-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@openproject/primer-view-components': minor
---

Add rubocop linter for `IconButton` component

<!-- Changed components: Primer::IconButton -->
7 changes: 7 additions & 0 deletions .changeset/eleven-pillows-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@openproject/primer-view-components': patch
---

Fixing ActionBar more menu items including buttons with no type

<!-- Changed components: Primer::Alpha::ActionBar -->
7 changes: 7 additions & 0 deletions .changeset/odd-pumas-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@openproject/primer-view-components': patch
---

Fix errors in older browsers with :popover-open

<!-- Changed components: Primer::Alpha::Tooltip -->
7 changes: 7 additions & 0 deletions .changeset/rude-owls-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@openproject/primer-view-components': patch
---

Centre anchored-position elements when their anchor is not present

<!-- Changed components: Primer::Alpha::Overlay -->
7 changes: 7 additions & 0 deletions .changeset/sour-parrots-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@openproject/primer-view-components': minor
---

Moving the render for the ActionBar::Item from the slot initializer to the call method.

<!-- Changed components: _none_ -->
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"vunguyentuan.vscode-postcss",
"DavidAnson.vscode-markdownlint"
],
"forwardPorts": [4000, 5400],
"appPort": [4000, 5400],
"forwardPorts": [4000],
"appPort": [4000],
"portsAttributes": {
"4000": {
"label": "demo"
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/welcome-message.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
👢 Your environment is all set up and bootstrapped.

🚀 To begin, start the server with the VS code task (⇧⌘B) or run
script/dev, which will start the Rails server at http://localhost:4000 and documentation at http://localhost:5400.
script/dev, which will start the Rails server at http://localhost:4000.

❔ Having other problems? Open an issue in the repo for support!
2 changes: 2 additions & 0 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ linters:
Enabled: false
Exclude:
- app/components/primer/layout_component.html.erb
Primer/Migrations/IconButtonComponent:
Enabled: true
Primer/Migrations/TruncateComponent:
Enabled: true
2 changes: 1 addition & 1 deletion .github/release_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ Please ensure these items are checked before merging.
### 🔎 Smoke test

- [ ] All CI checks pass
- [ ] Lookbook opens in a browser
- [ ] Successful integration test with OpenProject as a primary consumer
- [ ] Install the npm package locally
- [ ] Install the `primer_view_components` gem locally
- [ ] Verify no new build errors appear
- [ ] Verify no new linting errors appear
- [ ] Manually test critical paths
- [ ] Manually test release-specific bugfixes and/or features work as described
- [ ] Lookbook opens in a browser

### 🤔 Sanity test

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- name: Get specific changed files
id: changed-files
uses: tj-actions/changed-files@v37.6.0
uses: tj-actions/changed-files@v38.2.0
with:
files: |
**/*.md
Expand All @@ -38,7 +38,7 @@ jobs:
- uses: actions/checkout@v3
- name: Get specific changed files
id: changed-files
uses: tj-actions/changed-files@v37.6.0
uses: tj-actions/changed-files@v38.2.0
with:
files: |
app/**/*.rb
Expand All @@ -61,7 +61,7 @@ jobs:
- uses: actions/checkout@v3
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37.6.0
uses: tj-actions/changed-files@v38.2.0
with:
files: |
app/components/**/*.erb
Expand All @@ -81,7 +81,7 @@ jobs:
- uses: actions/checkout@v3
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37.6.0
uses: tj-actions/changed-files@v38.2.0
with:
files: |
app/components/**/*.ts
Expand All @@ -102,7 +102,7 @@ jobs:
- uses: actions/checkout@v3
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37.6.0
uses: tj-actions/changed-files@v38.2.0
with:
files: |
app/components/**/*.pcss
Expand Down
6 changes: 1 addition & 5 deletions app/components/primer/alpha/action_bar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class ActionBar < Primer::Component
c.with_leading_visual_icon(icon: icon)
end

render(Item.new) do
render(Primer::Beta::IconButton.new(id: item_id, icon: icon, "aria-label": label, size: @size, scheme: :invisible, **system_arguments))
end
Item.new(Primer::Beta::IconButton.new(id: item_id, icon: icon, "aria-label": label, size: @size, scheme: :invisible, **system_arguments))
},
divider: lambda {
@action_menu.with_divider(hidden: true) if @overflow_menu
Expand Down Expand Up @@ -68,8 +66,6 @@ def with_menu_item(id:, **system_arguments, &block)
system_arguments = {
**system_arguments,
hidden: true,
tag: :button,
type: "button",
"data-for": id,
"data-action": "click:action-bar#menuItemClick"
}
Expand Down
5 changes: 3 additions & 2 deletions app/components/primer/alpha/action_bar/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ module Alpha
class ActionBar
# ActionBar::Item is an internal component that wraps the items in a div with the `ActionBar-item` class.
class Item < Primer::Component
def initialize
def initialize(item_content)
@system_arguments = {
tag: :div,
data: {
targets: "action-bar.items"
},
classes: "ActionBar-item"
}
@item_content = item_content
end

def call
render(Primer::BaseComponent.new(**@system_arguments)) { content }
render(Primer::BaseComponent.new(**@system_arguments)) { render(@item_content) }
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions app/components/primer/alpha/overlay.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ anchored-position[popover]:not(.\:popover-open) {
display: none;
}

anchored-position.not-anchored::backdrop {
background-color: var(--overlay-backdrop-bgColor, var(--color-neutral-muted));
}

/* This reverts the declaration above for native popover, where `:popover-open` is supported */
@supports selector(:popover-open) {
anchored-position[popover]:not(.\:popover-open) {
Expand Down
35 changes: 27 additions & 8 deletions app/components/primer/alpha/tool_tip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ import type {AnchorAlignment, AnchorSide} from '@primer/behaviors'
import '@oddbird/popover-polyfill'
import {getAnchoredPosition} from '@primer/behaviors'

const isPopoverOpen = (() => {
let selector: string
function setSelector(el: Element) {
try {
selector = ':popover-open'
return el.matches(selector)
} catch {
try {
selector = ':open'
return el.matches(':open')
} catch {
selector = '.\\:popover-open'
return el.matches('.\\:popover-open')
}
}
}
return (el: Element) => (selector ? el.matches(selector) : setSelector(el))
})()

const TOOLTIP_ARROW_EDGE_OFFSET = 6
const TOOLTIP_SR_ONLY_CLASS = 'sr-only'
const TOOLTIP_OFFSET = 10
Expand All @@ -22,7 +41,7 @@ const DIRECTION_CLASSES = [
function closeOpenTooltips(except?: Element) {
for (const tooltip of openTooltips) {
if (tooltip === except) continue
if (tooltip.matches(':popover-open')) {
if (isPopoverOpen(tooltip)) {
tooltip.hidePopover()
} else {
openTooltips.delete(tooltip)
Expand Down Expand Up @@ -206,16 +225,16 @@ class ToolTipElement extends HTMLElement {

/* @deprecated */
set hiddenFromView(value: true | false) {
if (value && this.matches(':popover-open')) {
if (value && isPopoverOpen(this)) {
this.hidePopover()
} else if (!value && this.matches(':not(:popover-open)')) {
} else if (!value && !isPopoverOpen(this)) {
this.showPopover()
}
}

/* @deprecated */
get hiddenFromView() {
return !this.matches(':popover-open')
return !isPopoverOpen(this)
}

connectedCallback() {
Expand Down Expand Up @@ -262,7 +281,7 @@ class ToolTipElement extends HTMLElement {

async handleEvent(event: Event) {
if (!this.control) return
const showing = this.matches(':popover-open')
const showing = isPopoverOpen(this)

// Ensures that tooltip stays open when hovering between tooltip and element
// WCAG Success Criterion 1.4.13 Hoverable
Expand All @@ -277,9 +296,9 @@ class ToolTipElement extends HTMLElement {
const shouldHide = isMouseLeaveFromButton || isEscapeKeydown || isMouseDownOnButton || isOpeningOtherPopover

await Promise.resolve()
if (!showing && shouldShow && this.matches(':not(:popover-open)')) {
if (!showing && shouldShow && !isPopoverOpen(this)) {
this.showPopover()
} else if (showing && shouldHide && this.matches(':popover-open')) {
} else if (showing && shouldHide && isPopoverOpen(this)) {
this.hidePopover()
}

Expand Down Expand Up @@ -377,7 +396,7 @@ class ToolTipElement extends HTMLElement {

#updatePosition() {
if (!this.control) return
if (!this.#allowUpdatePosition || !this.matches(':popover-open')) return
if (!this.#allowUpdatePosition || !isPopoverOpen(this)) return

const position = getAnchoredPosition(this, this.control, {
side: this.#side,
Expand Down
17 changes: 13 additions & 4 deletions app/components/primer/anchored_position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,19 @@ export default class AnchoredPositionElement extends HTMLElement implements Posi

this.#animationFrame = requestAnimationFrame(() => {
const anchor = this.anchorElement
if (!anchor) return
const {left, top} = getAnchoredPosition(this, anchor, this)
this.style.top = `${top}px`
this.style.left = `${left}px`
this.classList.toggle('not-anchored', !anchor)
if (anchor) {
const {left, top} = getAnchoredPosition(this, anchor, this)
this.style.top = `${top}px`
this.style.left = `${left}px`
this.style.bottom = 'auto'
this.style.right = 'auto'
} else {
this.style.top = '0'
this.style.left = '0'
this.style.bottom = '0'
this.style.right = '0'
}
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/primer/beta/spinner.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
<circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" />
<circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" fill="none" />
<path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" />
<% end %>
1 change: 1 addition & 0 deletions demo/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require "primer/view_components"
require "primer/view_components/engine"
require "octicons"
require_relative "../../lib/primer/yard"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Expand Down
Loading

0 comments on commit 2a5c198

Please sign in to comment.