Skip to content

Commit

Permalink
Merge branch 'master' into 157-dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
verena-ifx authored and verena-ifx committed Jul 28, 2023
2 parents c61cf08 + 330baa0 commit add1bbf
Show file tree
Hide file tree
Showing 23 changed files with 288 additions and 308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,9 @@ <h2>Sidebar</h2>
<ifx-sidebar-item href="http://google.com" target="_blank" icon="image-16">Item Four</ifx-sidebar-item>
</ifx-sidebar>
<br />

<h2>Switch</h2>
<ifx-switch [disabled]="switchDisabled" [value]="switchChecked" (ifxChange)="toggleSwitchValue()"></ifx-switch>
<br />

</div>
9 changes: 9 additions & 0 deletions examples/stencil-components/angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export class AppComponent {
checkboxChecked = false;
checkboxError = false;
checkboxDisabled = false;
switchChecked = false;
switchDisabled = false;
radioError = false;
radioDisabled = false;
radioChecked = false;
Expand Down Expand Up @@ -45,6 +47,13 @@ export class AppComponent {
this.checkboxChecked = !this.checkboxChecked;
}

toggleSwitchValue() {
console.log("switch value change")
this.switchChecked = !this.switchChecked;
}
toggleSwitchDisabled() {
this.switchDisabled = !this.switchDisabled;
}
toggleRadioBtnDisabled() {
this.radioDisabled = !this.radioDisabled;
}
Expand Down
16 changes: 15 additions & 1 deletion examples/stencil-components/vanilla-cdn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ <h2>Sidebar</h2>
</ifx-sidebar>
<br />

<h2>Switch</h2>
<ifx-switch id="switch" disabled="false" value="false"></ifx-switch>
<br />
<h2>Single-Select</h2>
<ifx-choices id='single-select' disabled="false" type="single" value="undefined" name="single" placeholder="true"
placeholdervalue="Placeholder" remove-item-button="true" search-enabled="true"
Expand All @@ -147,6 +150,7 @@ <h2>Single-Select</h2>
let textInputValue = "";
let radioChecked = false;
let number = 1;
let switchChecked = false;

const form = document.querySelector("#form");
const anotherForm = document.querySelector("#another-form");
Expand All @@ -156,6 +160,7 @@ <h2>Single-Select</h2>
const textInput = document.querySelector('#text-input');
const radioBtn = document.querySelector('#radio-btn');
const numberIndicator = document.querySelector('#number-indicator');
const switchToggle = document.querySelector('#switch');
const singleSelect = document.querySelector('#single-select');


Expand All @@ -175,6 +180,7 @@ <h2>Single-Select</h2>
errorSpan.textContent = `Error: ${error}`;
valueSpan.textContent = `Value: ${checked}`;
textInputSpan.textContent = `Text field: ${textInputValue}`;
switchToggle.setAttribute('value', switchChecked);
}

function increaseNumber() {
Expand All @@ -194,7 +200,7 @@ <h2>Single-Select</h2>
document.addEventListener('DOMContentLoaded', (event) => {
form.addEventListener('submit', () => {
event.preventDefault();
console.log('Form submitted. Checkbox value:', checked);
console.log('Form submitted. \nCheckbox value:', checked, '\nSwitchToggle value', switchChecked);
});


Expand All @@ -204,6 +210,12 @@ <h2>Single-Select</h2>
updateValues();
});

switchToggle.addEventListener('ifxChange', (event) => {
console.log("switchToggle value change", event.detail);
switchChecked = !switchChecked;
updateValues();
});

toggleDisabledButton.addEventListener('click', () => {
disabled = !disabled;
updateValues();
Expand Down Expand Up @@ -231,6 +243,8 @@ <h2>Single-Select</h2>
radioChecked = !radioChecked;
});



singleSelect.addEventListener('ifxChange', (event) => {
console.log("single select value change", event.detail);
});
Expand Down
5 changes: 5 additions & 0 deletions examples/wrapper-components/react-javascript/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Navbar from './components/Navbar/Navbar';
import IconButton from './components/IconButton/IconButton';
import Tab from './components/Tab/Tab';
import Tag from './components/Tag/Tag';
import Switch from './components/Switch/Switch';

function App() {
return (
Expand Down Expand Up @@ -87,6 +88,10 @@ function App() {
<IconButton />
<br />

<h2>Switch</h2>
<Switch />
<br />

</div>

)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, { useState } from 'react';
import { IfxSwitch, IfxButton } from '@infineon/infineon-design-system-react';

function Switch() {
const [disabled, setDisabled] = useState(false);
const [switchChecked, setSwitchChecked] = useState(false);

const handleSubmit = (e) => {
e.preventDefault();
console.log('Form submitted. Switch value:', switchChecked);
};

const handleChange = (event) => {
console.log("Updating switch value: ", event.detail);
setSwitchChecked(event.detail);
};


return (
<div>
<form onSubmit={handleSubmit}>
<IfxSwitch disabled={disabled} onIfxChange={handleChange} value={switchChecked}>
label
</IfxSwitch>
<br />

<IfxButton type="submit">Submit</IfxButton>
</form>
<br />
<div>
<IfxButton variant="outline" onClick={() => setDisabled(!disabled)}>Toggle Disabled</IfxButton>


<IfxButton variant="outline" onClick={() => setSwitchChecked(!switchChecked)}>Toggle Value</IfxButton>

</div>
<br />
<span>Disabled: {String(disabled)} </span>
<br />

<span>Value: {String(switchChecked)}</span>
<br />
<br />
</div>
);
}

export default Switch;
2 changes: 2 additions & 0 deletions examples/wrapper-components/vue-javascript/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<NumberIndicator />
<Sidebar />
<IconButton />
<Switch />
</template>


Expand All @@ -35,6 +36,7 @@ import Tabs from './components/Tabs.vue'
import Sidebar from './components/Sidebar.vue'
import Navbar from './components/Navbar.vue'
import IconButton from './components/IconButton.vue'
import Switch from './components/Switch.vue'
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


<template>
<div>
<h2>Switch</h2>
<ifx-switch disabled="false" value="false" @ifxChange="console.log('switch changed')"></ifx-switch>
<br />
<br />
</div>
</template>






1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build:storybook": "lerna run build:storybook --scope @infineon/infineon-design-system-stencil",
"build:components-react": "lerna run build --scope @infineon/infineon-design-system-react",
"build:components-vue": "lerna run build --scope @infineon/infineon-design-system-vue",
"test": "lerna run test --scope @infineon/infineon-design-system-stencil",
"graph": "nx graph"
},
"workspaces": [
Expand Down
Loading

0 comments on commit add1bbf

Please sign in to comment.