This repository was archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Switch from React to Compose #134
Open
SerVB
wants to merge
3
commits into
master
Choose a base branch
from
compose-for-web-initial
base: master
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
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
33 changes: 0 additions & 33 deletions
33
...web/src/main/kotlin/org/jetbrains/projector/client/web/externalDeclarartion/npm-radium.kt
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
...in/org/jetbrains/projector/client/web/externalDeclarartion/npm-react-loading-indicator.kt
This file was deleted.
Oops, something went wrong.
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
97 changes: 97 additions & 0 deletions
97
...ctor-client-web/src/main/kotlin/org/jetbrains/projector/client/web/ui/LoadingIndicator.kt
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,97 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2019-2022 JetBrains s.r.o. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package org.jetbrains.projector.client.web.ui | ||
|
||
import androidx.compose.runtime.Composable | ||
import org.jetbrains.compose.web.ExperimentalComposeWebApi | ||
import org.jetbrains.compose.web.css.* | ||
import org.jetbrains.compose.web.css.selectors.Nth.Companion.Functional | ||
import org.jetbrains.compose.web.dom.Div | ||
|
||
/* The following loading indicator is inspired from https://loading.io/css/ (CC0 license). */ | ||
|
||
private const val CHILDREN_COUNT = 12 | ||
private val ANIMATION_DELAY = 0.1.s | ||
|
||
@OptIn(ExperimentalComposeWebApi::class) | ||
private object LoadingIndicatorStyleSheet : StyleSheet() { | ||
|
||
private val ldsSpinnerFrames by keyframes { | ||
0.percent { | ||
opacity(1) | ||
} | ||
|
||
100.percent { | ||
opacity(0) | ||
} | ||
} | ||
|
||
val ldsSpinner by style { | ||
color(Color.white) | ||
display(DisplayStyle.InlineBlock) | ||
position(Position.Relative) | ||
width(80.px) | ||
height(80.px) | ||
|
||
type("div") style { | ||
property("transform-origin", "40px 40px") | ||
animation(ldsSpinnerFrames) { | ||
duration(CHILDREN_COUNT * ANIMATION_DELAY) | ||
timingFunction(AnimationTimingFunction.Linear) | ||
iterationCount(null) // null is infinite | ||
} | ||
} | ||
|
||
type("div") + after style { | ||
property("content", """" """") // like `content: " ";` in css – to make divs have some volume | ||
display(DisplayStyle.Block) | ||
position(Position.Absolute) | ||
top(3.px) | ||
left(37.px) | ||
width(6.px) | ||
height(18.px) | ||
borderRadius(20.percent) | ||
backgroundColor(Color("#fff")) | ||
} | ||
|
||
repeat(CHILDREN_COUNT) { i -> | ||
type("div") + nthChild(Functional(b = i + 1)) style { // todo: what is functional? can we do without it? | ||
transform { rotate(i * (360.deg / CHILDREN_COUNT)) } | ||
property("animation-delay", | ||
(i + 1 - CHILDREN_COUNT) * ANIMATION_DELAY) // todo: can we add CHILDREN_COUNT to the multiplier to make it clearer? | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun LoadingIndicator() { | ||
Style(LoadingIndicatorStyleSheet) | ||
|
||
Div({ classes(LoadingIndicatorStyleSheet.ldsSpinner) }) { | ||
repeat(CHILDREN_COUNT) { | ||
Div() | ||
} | ||
} | ||
} |
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.
How these values are calculated? Or do they come from removed
radium
/react-loading-indicator
?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.
No, radium / react-loading-indicator are removed for good. Everything is taken from https://loading.io/css/ (CC0 license) now, just the first link after searching something like "css create loading indicator". Let me restore comment about that.
Actually, I haven't made any research how this thing works. Thank you for pushing me to understand it and finding the stuff that can be rewritten as constants.
I guess I should have spend more time on understanding this copy-pasted sample. Since switching to Compose isn't a high priority task, will do that a bit later. And will request your review afterwards.