Skip to content

Commit

Permalink
Adds experimental PointerIcon.fromKeyword function to change the brow…
Browse files Browse the repository at this point in the history
…ser cursor in Web source set (#1704)

Adds remaining cursors pointer icons in Web source set which are
available in https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
Note that not all of the cursors are available in all browsers and OS's
but they default to default one if not available
If you were planning a different approach, i'm open to feedback

Fixes
[https://youtrack.jetbrains.com/issue/CMP-6951/Consider-making-BrowserCursor-dataclass-public-or-add-more-PointerIcons-to-WasmJs-target](https://youtrack.jetbrains.com/issue/CMP-6951/Consider-making-BrowserCursor-dataclass-public-or-add-more-PointerIcons-to-WasmJs-target)

## Release Notes
### Features - Web
- Adds experimental PointerIcon.fromKeyword function to change the
browser cursor

---------

Signed-off-by: Apolo Studio <dev@composevisualeditor.com>
  • Loading branch information
apolostudio authored Dec 4, 2024
1 parent e839617 commit 20ed662
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@

package androidx.compose.ui.input.pointer

import androidx.compose.ui.ExperimentalComposeUiApi

object DummyPointerIcon : PointerIcon

internal data class BrowserCursor(val id: String): PointerIcon

/**
* Creates [PointerIcon] from provided cursor keyword.
* @param keyword one of the values representing the cursor appearance in a browser.
* @see <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/cursor">https://developer.mozilla.org/en-US/docs/Web/CSS/cursor</a>
*/
@ExperimentalComposeUiApi
fun PointerIcon.Companion.fromKeyword(keyword: String): PointerIcon {
return BrowserCursor(keyword)
}

internal actual val pointerIconDefault: PointerIcon = BrowserCursor("default")
internal actual val pointerIconCrosshair: PointerIcon = BrowserCursor("crosshair")
internal actual val pointerIconText: PointerIcon = BrowserCursor("text")
Expand Down

0 comments on commit 20ed662

Please sign in to comment.