-
Notifications
You must be signed in to change notification settings - Fork 54
Feature: uui-drag-handle
component
#1118
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
Open
bjarnef
wants to merge
3
commits into
umbraco:main
Choose a base branch
from
bjarnef:feature/drag-handle
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# uui-drag-handle | ||
|
||
 | ||
|
||
Umbraco style drag-handle component. | ||
|
||
## Installation | ||
|
||
### ES imports | ||
|
||
```zsh | ||
npm i @umbraco-ui/uui-drag-handle | ||
``` | ||
|
||
Import the registration of `<uui-drag-handle>` via: | ||
|
||
```javascript | ||
import '@umbraco-ui/uui-drag-handle'; | ||
``` | ||
|
||
When looking to leverage the `UUIDragHandleElement` base class as a type and/or for extension purposes, do so via: | ||
|
||
```javascript | ||
import { UUIDragHandleElement } from '@umbraco-ui/uui-drag-handle'; | ||
``` | ||
|
||
## Usage | ||
|
||
```html | ||
<uui-drag-handle></uui-drag-handle> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './uui-drag-handle.element'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { LabelMixin } from '@umbraco-ui/uui-base/lib/mixins'; | ||
import { defineElement } from '@umbraco-ui/uui-base/lib/registration'; | ||
import { css, html, LitElement } from 'lit'; | ||
import { ifDefined } from 'lit/directives/if-defined.js'; | ||
|
||
/** | ||
* @element uui-drag-handle | ||
*/ | ||
@defineElement('uui-drag-handle') | ||
export class UUIDragHandleElement extends LabelMixin('', LitElement) { | ||
render() { | ||
return html`<uui-icon | ||
name="drag" | ||
aria-label=${ifDefined(this.label)}></uui-icon>`; | ||
} | ||
|
||
static styles = [ | ||
css` | ||
:host { | ||
cursor: grab; | ||
} | ||
:host:active { | ||
cursor: grabbing; | ||
} | ||
`, | ||
]; | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'uui-drag-handle': UUIDragHandleElement; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Meta, StoryObj } from '@storybook/web-components'; | ||
|
||
import './uui-drag-handle.element'; | ||
import type { UUIDragHandleElement } from './uui-drag-handle.element'; | ||
import readme from '../README.md?raw'; | ||
|
||
const meta: Meta<UUIDragHandleElement> = { | ||
id: 'uui-drag-handle', | ||
title: 'Symbols/Drag Handle', | ||
component: 'uui-drag-handle', | ||
parameters: { | ||
readme: { markdown: readme }, | ||
docs: { | ||
source: { | ||
code: `<uui-drag-handle></uui-drag-handle>`, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<UUIDragHandleElement>; | ||
|
||
export const Overview: Story = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { html, fixture, expect } from '@open-wc/testing'; | ||
import { UUIDragHandleElement } from './uui-drag-handle.element'; | ||
|
||
describe('UUIDragHandleElement', () => { | ||
let element: UUIDragHandleElement; | ||
|
||
beforeEach(async () => { | ||
element = await fixture(html` <uui-drag-handle></uui-drag-handle> `); | ||
}); | ||
|
||
it('is defined with its own instance', () => { | ||
expect(element).to.be.instanceOf(UUIDragHandleElement); | ||
}); | ||
|
||
it('passes the a11y audit', async () => { | ||
await expect(element).shadowDom.to.be.accessible(); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "@umbraco-ui/uui-drag-handle", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"keywords": [ | ||
"Umbraco", | ||
"Custom elements", | ||
"Web components", | ||
"UI", | ||
"Lit", | ||
"Drag Handle" | ||
], | ||
"description": "Umbraco UI drag-handle component", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/umbraco/Umbraco.UI.git", | ||
"directory": "packages/uui-drag-handle" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/umbraco/Umbraco.UI/issues" | ||
}, | ||
"main": "./lib/index.js", | ||
"module": "./lib/index.js", | ||
"types": "./lib/index.d.ts", | ||
"type": "module", | ||
"customElements": "custom-elements.json", | ||
"files": [ | ||
"lib/**/*.d.ts", | ||
"lib/**/*.js", | ||
"custom-elements.json" | ||
], | ||
"dependencies": { | ||
"@umbraco-ui/uui-base": "1.14.0-rc.1" | ||
}, | ||
"scripts": { | ||
"build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js", | ||
"clean": "tsc --build --clean && rimraf -g dist lib/*.js lib/**/*.js *.tgz lib/**/*.d.ts custom-elements.json", | ||
"analyze": "web-component-analyzer **/*.element.ts --outFile custom-elements.json" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"homepage": "https://uui.umbraco.com/?path=/story/uui-drag-handle" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { UUIProdConfig } from '../rollup-package.config.mjs'; | ||
|
||
export default UUIProdConfig({ | ||
entryPoints: ['index'], | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js | ||
|
||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./lib", | ||
"rootDir": "./lib", | ||
"composite": true | ||
}, | ||
"include": ["./**/*.ts"], | ||
"exclude": ["./**/*.test.ts", "./**/*.story.ts"], | ||
"references": [ | ||
{ | ||
"path": "../uui-base" | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { svg } from 'lit'; | ||
|
||
export const iconDrag = svg`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="12" r="1"/><circle cx="9" cy="5" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="19" r="1"/></svg>`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To match the rest, I think this should be named
uui-symbol-drag-handle
.See
uui-symbol-sort
as a reference.Also I would prefere not to have it as an icon, but instead have it as SVG inside this specific component. To only enable getting this by using the symbol.
With that I think this will be really good :-)
Thanks
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, although I think the name is a bit longer than necessary 🙂
I thinn @madsrasmussen added other icons for drag handles, so I wondered if there are scenarios where it makes sense to use different icon.