Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Preact libraries to current version #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 27 additions & 38 deletions benchmarks/color-picker/preact/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = class extends preact.Component {
constructor(props) {
super(props);
this.state = {
selectedColorIndex: 0
selectedColorIndex: 0,
};
}

Expand All @@ -23,7 +23,7 @@ module.exports = class extends preact.Component {

handleColorClick(colorIndex) {
this.setState({
selectedColorIndex: colorIndex
selectedColorIndex: colorIndex,
});
}

Expand All @@ -34,45 +34,34 @@ module.exports = class extends preact.Component {
var selectedColor = colors[selectedColorIndex];
var self = this;

function renderColor(color, i) {
var style = {
backgroundColor: color.hex
};

var className = "color";
if (selectedColorIndex === i) {
className += " selected";
}

return (
<li
className={className}
style={style}
onClick={handleColorClick.bind(self, i)}
>
{color.name}
</li>
);
}

function renderColors(colors) {
if (colors.length) {
return (
<ul>
{colors.map(function(color, i) {
return renderColor(color, i);
})}
</ul>
);
} else {
return <div>No colors!</div>;
}
}

return (
<div class="colors">
<h1>Choose your favorite color:</h1>
<div class="colors">{renderColors(colors)}</div>
<div class="colors">
{colors.length ? (
<ul>
{colors.map(function(color, i) {
var className = "color";
if (selectedColorIndex === i) {
className += " selected";
}
return (
<li
className={className}
style={{
backgroundColor: color.hex,
}}
onClick={handleColorClick.bind(self, i)}
>
{color.name}
</li>
);
})}
</ul>
) : (
<div>No colors!</div>
)}
</div>
<div>
You chose:
<div class="chosen-color">{selectedColor.name}</div>
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/search-results/preact/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module.exports = class extends Component {
return (
<div className="search-results">
<div>
{searchResultsData.items.map(function(item, i) {
return <SearchResultsItem key={i} item={item} />;
{searchResultsData.items.map(function(item) {
return <SearchResultsItem key={item.id} item={item} />;
})}
</div>
<Footer />
Expand Down
Loading