Skip to content

Commit

Permalink
Update css-prop modifier to new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
wenincode authored and chris-hut committed Oct 16, 2023
1 parent b7295ee commit 73089ed
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@
}}

<@disclosure.Details as |details|>
<PagedCollection
@items={{or @items (array)}}
as |pager|>
<PagedCollection @items={{or @items (array)}} as |pager|>
<div
{{on-outside 'click' @disclosure.close}}
{{did-insert pager.viewport}}
{{on-resize pager.resize}}
{{css-prop '--paged-row-height' returns=pager.rowHeight}}
{{css-prop 'max-height' returns=pager.maxHeight}}
class={{class-map
(array 'paged-collection-scroll' (includes pager.type (array 'virtual-scroll' 'native-scroll')))
(array
'paged-collection-scroll' (includes pager.type (array 'virtual-scroll' 'native-scroll'))
)
}}
...attributes
>
{{yield (hash
Menu=(component 'menu'
disclosure=@disclosure
pager=pager
)
)}}
{{yield (hash Menu=(component 'menu' disclosure=@disclosure pager=pager))}}
</div>
</PagedCollection>
</@disclosure.Details>

</@disclosure.Details>
25 changes: 13 additions & 12 deletions ui/packages/consul-ui/app/components/menu/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
}}

<ul
role="menu"
role='menu'
style={{{style-map
(array 'height' (if (and @pager (not-eq @pager.type 'native-scroll')) @pager.totalHeight) 'px')
(array '--paged-start' (if (and @pager (not-eq @pager.type 'native-scroll')) @pager.startHeight) 'px')
(array
'--paged-start' (if (and @pager (not-eq @pager.type 'native-scroll')) @pager.startHeight) 'px'
)
}}}
{{did-insert (optional @pager.pane)}}
{{aria-menu
onclose=(or @onclose @disclosure.close)
openEvent=(or @event @disclosure.event)
}}
{{aria-menu onclose=(or @onclose @disclosure.close) openEvent=(or @event @disclosure.event)}}
>
{{yield (hash
Action=(component 'menu/action' disclosure=@disclosure)
Item=(component 'menu/item')
Separator=(component 'menu/separator')
items=@pager.items
)}}
{{yield
(hash
Action=(component 'menu/action' disclosure=@disclosure)
Item=(component 'menu/item')
Separator=(component 'menu/separator')
items=@pager.items
)
}}
</ul>
9 changes: 4 additions & 5 deletions ui/packages/consul-ui/app/modifiers/css-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import { inject as service } from '@ember/service';

export default class CSSPropModifier extends Modifier {
@service('-document') doc;
didReceiveArguments() {
const params = this.args.positional;
const options = this.args.named;
const returns = params[1] || options.returns;
returns(this.doc.defaultView.getComputedStyle(this.element).getPropertyValue(params[0]));

modify(element, positional, named) {
const returns = positional[1] || named?.returns;
returns(this.doc.defaultView.getComputedStyle(element).getPropertyValue(positional[0]));
}
}

0 comments on commit 73089ed

Please sign in to comment.