Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
5752900b
Verified
Commit
5752900b
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
refacotr: made info use children instead of props
parent
f27bfd2a
No related branches found
No related tags found
1 merge request
!8
Support for react.js components
Pipeline
#1148
passed
2 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/web/react/app.tsx
+28
-29
28 additions, 29 deletions
examples/web/react/app.tsx
examples/web/react/components/info/info.tsx
+3
-3
3 additions, 3 deletions
examples/web/react/components/info/info.tsx
with
31 additions
and
32 deletions
examples/web/react/app.tsx
+
28
−
29
View file @
5752900b
...
...
@@ -15,34 +15,6 @@ export const App = () => {
const
[
count
,
setCount
]
=
useState
(
0
);
const
getText
=
()
=>
`Hello World
${
count
}
`
;
const
onClick
=
()
=>
setCount
(
count
+
1
);
const
pairs
=
()
=>
[
<
Pair
key
=
"tobias"
name
=
{
"
Tobias
"
}
value
=
{
`Count
${
count
}
`
}
/>,
<
Pair
key
=
"matias"
name
=
{
"
Matias
"
}
value
=
{
"
3
"
}
/>,
<
Pair
key
=
"button-tobias"
name
=
{
"
Button Increment
"
}
valueNode
=
{
<
ButtonIncrement
value
=
{
200
}
delta
=
{
100
}
min
=
{
0
}
suffix
=
{
"
Hz
"
}
/>
}
/>,
<
Pair
key
=
"button-cpu"
name
=
{
"
Button Switch
"
}
valueNode
=
{
<
ButtonSwitch
options
=
{
[
"
NEO
"
,
"
CLASSIC
"
]
}
size
=
{
"
large
"
}
style
=
{
[
"
simple
"
]
}
onChange
=
{
(
v
)
=>
alert
(
v
)
}
/>
}
/>
];
return
(
<>
<
Button
text
=
{
getText
()
}
onClick
=
{
onClick
}
/>
...
...
@@ -52,7 +24,34 @@ export const App = () => {
imageAlt
=
"tobias"
onClick
=
{
onClick
}
/>
<
Info
pairs
=
{
pairs
()
}
/>
<
Info
>
<
Pair
key
=
"tobias"
name
=
{
"
Tobias
"
}
value
=
{
`Count
${
count
}
`
}
/>
<
Pair
key
=
"matias"
name
=
{
"
Matias
"
}
value
=
{
"
3
"
}
/>
<
Pair
key
=
"button-tobias"
name
=
{
"
Button Increment
"
}
valueNode
=
{
<
ButtonIncrement
value
=
{
200
}
delta
=
{
100
}
min
=
{
0
}
suffix
=
{
"
Hz
"
}
/>
}
/>
<
Pair
key
=
"button-cpu"
name
=
{
"
Button Switch
"
}
valueNode
=
{
<
ButtonSwitch
options
=
{
[
"
NEO
"
,
"
CLASSIC
"
]
}
size
=
{
"
large
"
}
style
=
{
[
"
simple
"
]
}
onChange
=
{
(
v
)
=>
alert
(
v
)
}
/>
}
/>
</
Info
>
</>
);
};
...
...
This diff is collapsed.
Click to expand it.
examples/web/react/components/info/info.tsx
+
3
−
3
View file @
5752900b
...
...
@@ -3,7 +3,7 @@ import React, { FC, ReactNode } from "react";
import
"
./info.css
"
;
type
InfoProps
=
{
pairs
?:
ReactNode
[]
;
children
?:
ReactNode
;
style
?:
string
[];
};
...
...
@@ -18,9 +18,9 @@ type InfoProps = {
* to build the info pairs.
* @returns The info component with the associated pairs.
*/
export
const
Info
:
FC
<
InfoProps
>
=
({
pairs
=
[],
style
=
[]
})
=>
{
export
const
Info
:
FC
<
InfoProps
>
=
({
children
=
[],
style
=
[]
})
=>
{
const
classes
=
()
=>
[
"
info
"
,
...
style
].
join
(
"
"
);
return
<
dl
className
=
{
classes
()
}
>
{
pairs
}
</
dl
>;
return
<
dl
className
=
{
classes
()
}
>
{
children
}
</
dl
>;
};
export
default
Info
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment