Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
4f013030
Commit
4f013030
authored
Apr 21, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Apr 25, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate presentational-component to TS
parent
ba92ed1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
presentational-component.tsx
src/shared/presentational-component.tsx
+43
-0
No files found.
src/shared/presentational-component.
js
→
src/shared/presentational-component.
tsx
View file @
4f013030
import
classnames
from
'classnames'
;
import
classnames
from
'classnames'
;
import
type
{
JSX
,
ComponentChildren
,
Ref
}
from
'preact'
;
import
{
downcastRef
}
from
'./type-coercions'
;
import
{
downcastRef
}
from
'./type-coercions'
;
/**
type
HTMLDivAttributes
=
JSX
.
HTMLAttributes
<
HTMLDivElement
>
;
* @typedef {import('preact').JSX.HTMLAttributes<HTMLDivElement>} HTMLDivAttributes
*/
/**
export
type
PresentationalComponentProps
=
{
* @typedef PresentationalComponentProps
children
?:
ComponentChildren
;
* @prop {import('preact').ComponentChildren} [children]
/** Optional extra CSS classes to append to the component's default classes */
* @prop {string|string[]} [classes] - Optional extra CSS classes to append to the
classes
?:
string
|
string
[];
* component's default classes
elementRef
?:
Ref
<
HTMLElement
>
;
* @prop {import('preact').Ref<HTMLElement>} [elementRef]
};
*/
/**
/**
* Make a presentational component which wraps children to apply layout and
* Make a presentational component which wraps children to apply layout and
* styling.
* styling.
*
*
* @param {string} displayName
* @param classes - CSS classes for this component
* @param {string|string[]} classes - CSS classes for this component
*/
*/
export
function
makePresentationalComponent
(
displayName
,
classes
)
{
export
function
makePresentationalComponent
(
/**
displayName
:
string
,
* @param {HTMLDivAttributes & PresentationalComponentProps} props
classes
:
string
|
string
[]
*/
)
{
function
PresentationalComponent
({
function
PresentationalComponent
({
classes
:
extraClasses
,
classes
:
extraClasses
,
elementRef
,
elementRef
,
children
,
children
,
...
htmlAttributes
...
htmlAttributes
})
{
}
:
HTMLDivAttributes
&
PresentationalComponentProps
)
{
return
(
return
(
<
div
<
div
className=
{
classnames
(
classes
,
extraClasses
)
}
className=
{
classnames
(
classes
,
extraClasses
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment