Skip to content

Commit f6ee050

Browse files
committed
Add code documentation
1 parent 5c383fb commit f6ee050

File tree

1 file changed

+92
-1
lines changed

1 file changed

+92
-1
lines changed

src/Fable.React.TransitionGroup/Fable.Helpers.React.TransitionGroup.fs

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,47 @@ module TransitionGroup =
2020

2121
[<RequireQualifiedAccess>]
2222
type TransitionProp =
23+
/// Show the element; triggers the `enter` or `exit` states
2324
| In of bool
25+
/// Normally a element is not transitioned if it is shown when the `transition` element mounts.
26+
/// If you want to transition on the first mount set appear to true,
27+
/// and the element will transition in as soon as the `transition` mounts.
2428
| Appear of bool
29+
/// Enable or disable enter transitions.
2530
| Enter of bool
31+
/// Enable or disable exit transitions.
2632
| Exit of bool
33+
/// By default the child element is mounted immediately along with the parent `transition` element.
34+
/// If you want to "lazy mount" the element on the first `In true` you can set `MountOnEnter`.
35+
/// After the first enter transition the element will stay mounted, even on `exited`, unless you also specify `UnmountOnExit`.
2736
| MountOnEnter of bool
37+
/// By default the child element stays mounted after it reaches the `exited` state.
38+
/// Set `UnmountOnExit` if you'd prefer to unmount the element after it finishes exiting.
2839
| UnmountOnExit of bool
40+
/// The duration of the transition, in milliseconds. Required unless `AddEndListener` is provided
2941
| Timeout of U2<int, Timeout>
42+
/// Add a custom transition end trigger.
43+
/// Called with the transitioning DOM node and a done callback.
44+
/// Allows for more fine grained transition end logic.
45+
/// Note: Timeouts are still used as a fallback if provided.
3046
| AddEndListener of (Browser.HTMLElement -> (unit -> unit) -> unit)
47+
/// A transition callback fired immediately after the `enter` or `appear` class is applied.
3148
| OnEnter of (Browser.HTMLElement -> bool -> unit)
49+
/// A transition callback fired immediately after the `enter-active` or `appear-active` class is applied.
3250
| OnEntering of (Browser.HTMLElement -> bool -> unit)
51+
/// A transition callback fired immediately after the `enter` or `appear` classes are removed and the done class is added to the DOM node.
3352
| OnEntered of (Browser.HTMLElement -> bool -> unit)
53+
/// A transition callback fired immediately after the `exit` class is applied.
3454
| OnExit of (Browser.HTMLElement -> unit)
55+
/// A transition callback fired immediately after the `exit-active` is applied.
3556
| OnExiting of (Browser.HTMLElement -> unit)
57+
/// A transition callback fired immediately after the `exit` classes are removed and the exit-done class is added to the DOM node.
3658
| OnExited of (Browser.HTMLElement -> unit)
37-
| Children of U2<React.ReactElement, (TransitionStatus -> React.ReactElement)>
59+
/// A function child can be used instead of a React element.
60+
/// This function is called with the current transition status
61+
/// (`entering`, `entered`, `exiting`, `exited`, `unmounted`),
62+
/// which can be used to apply context specific props to a element.
63+
| Children of U2<React.ReactElement, TransitionStatus -> React.ReactElement>
3864
| [<CompiledName "className">] Class of string
3965
| Ref of (obj -> obj)
4066
| Key of string
@@ -54,21 +80,53 @@ module TransitionGroup =
5480

5581
[<RequireQualifiedAccess>]
5682
type CSSTransitionProp =
83+
/// Show the element; triggers the `enter` or `exit` states
5784
| In of bool
85+
/// Normally a element is not transitioned if it is shown when the `transition` element mounts.
86+
/// If you want to transition on the first mount set appear to true,
87+
/// and the element will transition in as soon as the `transition` mounts.
5888
| Appear of bool
89+
/// Enable or disable enter transitions.
5990
| Enter of bool
91+
/// Enable or disable exit transitions.
6092
| Exit of bool
93+
/// By default the child element is mounted immediately along with the parent `transition` element.
94+
/// If you want to "lazy mount" the element on the first `In true` you can set `MountOnEnter`.
95+
/// After the first enter transition the element will stay mounted, even on `exited`, unless you also specify `UnmountOnExit`.
6196
| MountOnEnter of bool
97+
/// By default the child element stays mounted after it reaches the `exited` state.
98+
/// Set `UnmountOnExit` if you'd prefer to unmount the element after it finishes exiting.
6299
| UnmountOnExit of bool
100+
/// The duration of the transition, in milliseconds. Required unless `AddEndListener` is provided
63101
| Timeout of U2<int, Timeout>
102+
/// Add a custom transition end trigger.
103+
/// Called with the transitioning DOM node and a done callback.
104+
/// Allows for more fine grained transition end logic.
105+
/// Note: Timeouts are still used as a fallback if provided.
64106
| AddEndListener of (Browser.HTMLElement -> (unit -> unit) -> unit)
107+
/// A transition callback fired immediately after the `enter` or `appear` class is applied.
65108
| OnEnter of (Browser.HTMLElement -> bool -> unit)
109+
/// A transition callback fired immediately after the `enter-active` or `appear-active` class is applied.
66110
| OnEntering of (Browser.HTMLElement -> bool -> unit)
111+
/// A transition callback fired immediately after the `enter` or `appear` classes are removed and the done class is added to the DOM node.
67112
| OnEntered of (Browser.HTMLElement -> bool -> unit)
113+
/// A transition callback fired immediately after the `exit` class is applied.
68114
| OnExit of (Browser.HTMLElement -> unit)
115+
/// A transition callback fired immediately after the `exit-active` is applied.
69116
| OnExiting of (Browser.HTMLElement -> unit)
117+
/// A transition callback fired immediately after the `exit` classes are removed and the exit-done class is added to the DOM node.
70118
| OnExited of (Browser.HTMLElement -> unit)
119+
/// A function child can be used instead of a React element.
120+
/// This function is called with the current transition status
121+
/// (`entering`, `entered`, `exiting`, `exited`, `unmounted`),
122+
/// which can be used to apply context specific props to a element.
71123
| Children of U2<React.ReactElement, TransitionStatus -> React.ReactElement>
124+
/// The animation ClassNames applied to the element as it enters or exits.
125+
/// A single name can be provided and it will be suffixed for each stage: e.g.
126+
///
127+
/// `classNames="fade"` applies `fade-enter`, `fade-enter-active`,
128+
/// `fade-exit`, `fade-exit-active`, `fade-appear`, and `fade-appear-active`.
129+
/// Each individual classNames can also be specified independently.
72130
| ClassNames of U2<string, CSSTransitionClassNames>
73131
| [<CompiledName "className">] Class of string
74132
| Ref of (obj -> obj)
@@ -78,29 +136,62 @@ module TransitionGroup =
78136

79137
[<RequireQualifiedAccess>]
80138
type TransitionGroupProp =
139+
/// `transitionGroup` renders a <div> by default.
140+
/// You can change this behavior by providing a component prop.
141+
/// If you use React v16+ and would like to avoid a wrapping <div> element you can pass in `Component null`.
142+
/// This is useful if the wrapping div borks your css styles.
81143
| Component of React.ReactType
144+
/// You may need to apply reactive updates to a child as it is exiting.
145+
/// This is generally done by using cloneElement however in the case of an
146+
/// exiting child the element has already been removed and not accessible to the consumer.
82147
| ChildFactory of (React.ReactElement -> React.ReactElement)
83148
| [<CompiledName "className">] Class of string
84149
| Ref of (obj -> obj)
85150
| Key of string
86151
static member Custom(key: string, value: obj): TransitionGroupProp =
87152
unbox(key, value)
88153

154+
/// The transition element lets you describe a transition from one element
155+
/// state to another _over time_ with a simple declarative API. Most commonly
156+
/// It's used to animate the mounting and unmounting of Component, but can also
157+
/// be used to describe in-place transition states as well.
158+
///
159+
/// By default the `transition` element does not alter the behavior of the
160+
/// element it renders, it only tracks Enter and Exit states for the elements.
161+
/// It's up to you to give meaning and effect to those states. For example we can
162+
/// add styles to a element when it enters or exits.
89163
let transition (props: TransitionProp list) (child: React.ReactElement): React.ReactElement =
90164
let props = (TransitionProp.Children !^child)::props
91165
ofImport "Transition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
92166

167+
/// The transition element lets you describe a transition from one component
168+
/// state to another _over time_ with a simple declarative API. Most commonly
169+
/// It's used to animate the mounting and unmounting of Component, but can also
170+
/// be used to describe in-place transition states as well.
171+
///
172+
/// By default the `transition` element does not alter the behavior of the
173+
/// element it renders, it only tracks Enter and Exit states for the elements.
174+
/// It's up to you to give meaning and effect to those states. For example we can
175+
/// add styles to a element when it enters or exits.
93176
let transitionWithRender (props: TransitionProp list) (render: TransitionStatus -> React.ReactElement): React.ReactElement =
94177
let props = (TransitionProp.Children !^render)::props
95178
ofImport "Transition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
96179

180+
/// A transition element using CSS transitions and animations.
181+
/// See `transition` for more information.
97182
let cssTransition (props: CSSTransitionProp list) (child: React.ReactElement): React.ReactElement =
98183
let props = (CSSTransitionProp.Children !^child)::props
99184
ofImport "CSSTransition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
100185

186+
/// A transition element using CSS transitions and animations.
187+
/// See `transitionWithRender` for more information.
101188
let cssTransitionWithRender (props: CSSTransitionProp list) (render: TransitionStatus -> React.ReactElement): React.ReactElement =
102189
let props = (CSSTransitionProp.Children !^render)::props
103190
ofImport "CSSTransition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
104191

192+
/// The `transitionGroup` element manages a set of `transition` elements
193+
/// in a list. Like with the `transition` element, `transitionGroup`, is a
194+
/// state machine for managing the mounting and unmounting of elements over
195+
/// time.
105196
let transitionGroup (props: TransitionGroupProp list) (children: React.ReactElement list): React.ReactElement =
106197
ofImport "TransitionGroup" "react-transition-group" (keyValueList CaseRules.LowerFirst props) children

0 commit comments

Comments
 (0)