-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added one more post — just reusing test from docs
- Loading branch information
1 parent
493c980
commit e713c61
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
_posts/2019-01-31-building-sortable-lists-with-scalajs-react.md
This file contains 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,52 @@ | ||
--- | ||
layout: post | ||
title: Building Sortable lists with scalajs-react | ||
tags: [react-sortable-hoc, react, scalajs] | ||
bigimg: /img/???.jpg | ||
gh-repo: dborisenko/scalajs-react-components | ||
gh-badge: [star, fork, follow] | ||
--- | ||
|
||
# React Sortable (HOC) | ||
|
||
React Sortable (HOC) is a set of higher-order components to turn any list into an animated, touch-friendly, sortable list. It is possible to use it with Scala. Here I will provide short instructions how to do that. | ||
|
||
## Dependencies | ||
|
||
The code is based one the [react-sortable-hoc](https://github.com/dborisenko/scalajs-react-components#react-sortable-hoc) for [React Sortable (HOC)](https://github.com/clauderic/react-sortable-hoc) component. It is written using [scalajs-react](https://github.com/japgolly/scalajs-react) library for ScalaJs. | ||
|
||
Add dependencies in `build.sbt`: | ||
|
||
```scala | ||
libraryDependencies ++= Seq( | ||
"com.dbrsn.scalajs.react.components" %%% "react-sortable-hoc" % "0.3.1" | ||
) | ||
npmDependencies in Compile ++= Seq( | ||
"react-sortable-hoc" -> "1.4.0", | ||
"react" -> "16.7.0", | ||
"react-dom" -> "16.7.0" | ||
) | ||
``` | ||
|
||
## Usage | ||
|
||
Example of usage: | ||
|
||
```scala | ||
case class Model(text: String) | ||
case class Props(model: Model) | ||
|
||
val item1 = "Test 1" | ||
val item2 = "Test 2" | ||
|
||
SortableList[Model, Props].Props( | ||
listToDisplay = List(Model(item1), Model(item2)), | ||
sortableContainerProps = SortableContainer.Props(), | ||
externalProps = Props, | ||
itemComponent = raw | ||
).render | ||
``` | ||
|
||
## Source Code | ||
|
||
Source code can be found [here](https://github.com/dborisenko/scalajs-react-components) |