Skip to content

Commit

Permalink
Merge branch 'master' into 193-review-textinput
Browse files Browse the repository at this point in the history
  • Loading branch information
verena-ifx authored and verena-ifx committed Jun 21, 2023
2 parents 2042729 + 6cd0e1f commit 5d4a55b
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 44 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,6 @@ typings/

.angular

packages/components/src/components.d.ts
packages/components/src/components.d.ts

.angular
30 changes: 28 additions & 2 deletions examples/wrapper-components/react-javascript/src/App.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
import './App.css';

import Button from './components/Button/button';

import TextField from './components/TextFIeld/TextField';

import ProgressBar from './components/ProgressBar/ProgressBar';

import SearchBar from './components/SearchBar/SearchBar';
import Accordion from './components/Accordion/Accordion';


function App() {




return (
<div>
<TextField />
<h1 className="header">Stencil Framework integration - React + JS</h1>

<h2>Search Bar</h2>
<SearchBar />
<br />

<h2>Button</h2>
<Button />
<br />

<h2>Progress Bar</h2>
<ProgressBar />
<br />

<h2>Text Field</h2>
<TextField />
<br />

<h2>Accordion</h2>
<Accordion />

</div>

)
}

export default App;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { IfxButton } from '@infineon/infineon-design-system-react';

function Button() {
return (
<div >
<IfxButton color='primary'>Yes</IfxButton>
<IfxButton color='secondary'>No</IfxButton>
</div>
)
}

export default Button;
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import React from 'react';
import { IfxProgressBar } from '@infineon/infineon-design-system-react';
import React, { useState } from 'react';
import { IfxProgressBar, IfxButton } from '@infineon/infineon-design-system-react';

function ProgressBar() {
const [progressValue, setProgressValue] = useState(25);

// Define your methods here
const updateProgressOnClick = () => {
setProgressValue((currentValue) => {
console.log("updating progress-bar value ", progressValue)
if (currentValue < 100) {
return currentValue + 10;
} else {
return 10;
}
});
};

return (
<div>
<IfxProgressBar value={50} showLabel={true}></IfxProgressBar>
</div>
<IfxProgressBar value={progressValue} showLabel={true}></IfxProgressBar>
<IfxButton onClick={updateProgressOnClick} variant="outline" href="" target="_blank" color="primary" size="s"
disabled={false} icon={false}>
Update Progress
</IfxButton>
</div >
);
}

export default ProgressBar;
export default ProgressBar;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { IfxSearchBar } from '@infineon/infineon-design-system-react';

function SearchBar() {
const handleSearch = (event) => {
console.log("handling search: ", event.detail?.detail)
};
return (
<div >
<IfxSearchBar onIfxChange={handleSearch} style={{ width: '100%' }} show-close-button="true"></IfxSearchBar>

</div>
)
}

export default SearchBar;


27 changes: 4 additions & 23 deletions packages/components/src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,36 +91,17 @@

.btn {

& ifx-icon:empty {
display: none;
}

&.btn-s {
font-size: tokens.$font-size-s;
min-width: 71px;
min-height: 32px;
line-height: 16px;
}

&.icon-button {
min-width: initial;
min-height: initial;
width: 40px;
height: 40px;
padding: 0;
justify-content: center;

&.btn-round {
border-radius: 100px;
}

&.btn-square {
border-radius: 1px;
}

&.btn-s {
width: 32px;
height: 32px;
}

}

&.btn-primary,
&.btn-outline-primary,
&.btn-secondary,
Expand Down
30 changes: 18 additions & 12 deletions packages/components/src/components/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Prop, h, Host, Method, Element } from '@stencil/core';
import { Component, Prop, h, Host, Method, Element, Watch, State } from '@stencil/core';
import classNames from 'classnames';

@Component({
Expand All @@ -10,30 +10,37 @@ import classNames from 'classnames';
export class Button {
@Prop() variant: 'solid' | 'outline' | 'outline-text' = 'solid';
@Prop() color: 'primary' | 'secondary' | 'success' | 'danger' | 'warning' = 'primary';
@Prop() size: string = 'm';
@Prop() size: string;
@Prop() disabled: boolean;
@Prop() icon: string;
@Prop({ mutable: true }) position: string = 'left'

@Prop() position: string = 'left'
@State() internalPosition: string;
@Prop() href: string;
@Prop() target: string = '_self';
@Element() el;

private focusableElement: HTMLElement;

@Watch('position')
reassignPosition(newValue: string) {
if (newValue && newValue !== this.internalPosition) {
if(newValue.toUpperCase() === "LEFT" || newValue.toUpperCase() === "RIGHT")
this.internalPosition = newValue;
}
}

@Method()
async setFocus() {
this.focusableElement.focus();
}

componentWillLoad() {
if (this.position.toUpperCase() !== "LEFT") {
this.position = 'right';
}
this.internalPosition = 'left';
} else this.internalPosition = this.position;
}



render() {
return (
<Host>
Expand All @@ -45,20 +52,19 @@ export class Button {
target={this.target}
rel={this.target === '_blank' ? 'noopener noreferrer' : undefined}
>
{this.icon && this.position.toUpperCase() === "LEFT" && <ifx-icon icon={this.icon}></ifx-icon>}
{this.icon && this.internalPosition.toUpperCase() === "LEFT" && <ifx-icon icon={this.icon}></ifx-icon>}
<slot></slot>
{this.icon && this.position.toUpperCase() === "RIGHT" && <ifx-icon icon={this.icon}></ifx-icon>}
{this.icon && this.internalPosition.toUpperCase() === "RIGHT" && <ifx-icon icon={this.icon}></ifx-icon>}

</a>
) : (
<button
class={this.getClassNames()}

type="button"
>
{this.icon && this.position.toUpperCase() === "LEFT" && <ifx-icon icon={this.icon}></ifx-icon>}
{this.icon && this.internalPosition.toUpperCase() === "LEFT" && <ifx-icon icon={this.icon}></ifx-icon>}
<slot></slot>
{this.icon && this.position.toUpperCase() === "RIGHT" && <ifx-icon icon={this.icon}></ifx-icon>}
{this.icon && this.internalPosition.toUpperCase() === "RIGHT" && <ifx-icon icon={this.icon}></ifx-icon>}
</button>
)}
</Host>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/button/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
| `href` | `href` | | `string` | `undefined` |
| `icon` | `icon` | | `string` | `undefined` |
| `position` | `position` | | `string` | `'left'` |
| `size` | `size` | | `string` | `'m'` |
| `size` | `size` | | `string` | `undefined` |
| `target` | `target` | | `string` | `'_self'` |
| `variant` | `variant` | | `"outline" \| "outline-text" \| "solid"` | `'solid'` |

Expand Down

0 comments on commit 5d4a55b

Please sign in to comment.