Skip to content

Commit da3fb09

Browse files
committed
Initial API for react-transition-group
1 parent 0514b49 commit da3fb09

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

build.fsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ let packages =
2222
"src/Fable.ReactLeaflet/Fable.ReactLeaflet.fsproj"
2323
"src/Fable.ReactGoogleMaps/Fable.ReactGoogleMaps.fsproj"
2424
"src/Fable.Recharts/Fable.Recharts.fsproj"
25+
"src/Fable.React.TransitionGroup/Fable.React.TransitionGroup.fsproj"
2526
]
2627

2728
let addToPath newPath =
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
module Fable.Helpers.React.TransitionGroup
2+
3+
open Fable.Core
4+
open Fable.Core.JsInterop
5+
open Fable.Import
6+
open Fable.Helpers.React
7+
open Fable.Helpers.React.Props
8+
9+
type Timeout = {
10+
enter: int option
11+
exit: int option
12+
}
13+
14+
type TransitionStatus =
15+
| [<CompiledName("entering")>] Entering
16+
| [<CompiledName("entered")>] Entered
17+
| [<CompiledName("exiting")>] Exiting
18+
| [<CompiledName("exited")>] Exited
19+
| [<CompiledName("unmounted")>] Unmounted
20+
21+
type TransitionProps =
22+
| In of bool
23+
| Appear of bool
24+
| Enter of bool
25+
| Exit of bool
26+
| MountOnEnter of bool
27+
| UnmountOnExit of bool
28+
| Timeout of U2<int, Timeout>
29+
| AddEndListener of (Browser.HTMLElement -> (unit -> unit) -> unit)
30+
| OnEnter of (Browser.HTMLElement -> bool -> unit)
31+
| OnEntering of (Browser.HTMLElement -> bool -> unit)
32+
| OnEntered of (Browser.HTMLElement -> bool -> unit)
33+
| OnExit of (Browser.HTMLElement -> unit)
34+
| OnExiting of (Browser.HTMLElement -> unit)
35+
| OnExited of (Browser.HTMLElement -> unit)
36+
| Children of U2<React.ReactNode, TransitionStatus -> React.ReactNode>
37+
interface IProp
38+
39+
type CSSTransitionClassNames = {
40+
appear: string option
41+
appearActive: string option
42+
enter: string option
43+
enterActive: string option
44+
enterDone: string option
45+
exit: string option
46+
exitActive: string option
47+
exitDone: string option
48+
}
49+
50+
type CSSTransitionProps =
51+
| ClassNames of U2<string, CSSTransitionClassNames>
52+
interface IProp
53+
54+
type TransitionGroupProps =
55+
| Component of React.ReactType
56+
| ChildFactory of (React.ReactElement -> React.ReactElement)
57+
interface IProp
58+
59+
let private asNode (el: React.ReactElement): React.ReactNode =
60+
!^(!^el: React.ReactChild)
61+
62+
let transition (props: IProp list) (child: React.ReactElement): React.ReactElement =
63+
let props = (Children !^(asNode child) :> IProp)::props
64+
ofImport "Transition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
65+
66+
let transitionWithRender (props: IProp list) (render: TransitionStatus -> React.ReactNode): React.ReactElement =
67+
let props = (Children !^render :> IProp)::props
68+
ofImport "Transition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
69+
70+
let cssTransition (props: IProp list) (child: React.ReactElement): React.ReactElement =
71+
let props = (Children !^(asNode child) :> IProp)::props
72+
ofImport "CSSTransition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
73+
74+
let cssTransitionWithRender (props: IProp list) (render: TransitionStatus -> React.ReactNode): React.ReactElement =
75+
let props = (Children !^render :> IProp)::props
76+
ofImport "CSSTransition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
77+
78+
let transitionGroup (props: IProp list) (children: React.ReactElement list): React.ReactElement =
79+
ofImport "TransitionGroup" "react-transition-group" (keyValueList CaseRules.LowerFirst props) children
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<Version>0.0.1</Version>
5+
<PackageVersion>0.0.1-alpha-001</PackageVersion>
6+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
7+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<Compile Include="Fable.Helpers.React.TransitionGroup.fs" />
11+
</ItemGroup>
12+
<ItemGroup>
13+
<ProjectReference Include="../Fable.React/Fable.React.fsproj" />
14+
</ItemGroup>
15+
<ItemGroup>
16+
<Content Include="*.fsproj; *.fs" PackagePath="fable\" />
17+
</ItemGroup>
18+
<Import Project="..\..\.paket\Paket.Restore.targets" />
19+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### 0.0.1-alpha-001
2+
3+
- Release a first alpha version
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FSharp.Core
2+
Fable.Core
3+
Fable.Import.Browser

0 commit comments

Comments
 (0)