Skip to content

Commit

Permalink
Fixed #108 Configurability for some Box-Sizing properties
Browse files Browse the repository at this point in the history
  • Loading branch information
MscrmTools committed Dec 5, 2022
1 parent d097288 commit ae8960f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
17 changes: 14 additions & 3 deletions ActionButton/ActionButton/ButtonControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react'
import {Stack} from '@fluentui/react/lib/Stack';
import {IBaseButtonProps, IBaseButtonState, IButtonStyles, PrimaryButton} from '@fluentui/react/lib/Button';
import { IIconProps } from '@fluentui/react';
import { IconButton } from 'office-ui-fabric-react/lib/components/Button/IconButton/IconButton';

export interface IButtonControlProps extends IBaseButtonProps{
hoverBackgroundColor:string,
Expand All @@ -21,28 +22,38 @@ export default class ButtonControl extends React.Component<IButtonControlProps,
root:{
backgroundColor:this.props.style?.backgroundColor ?? "#0078d4",
borderColor:this.props.style?.borderColor ?? "#0078d4",
color:this.props.style?.color ?? "#FFFFFF"
color:this.props.style?.color ?? "#FFFFFF",
width:this.props.style?.width
},
rootHovered:{
backgroundColor:this.props.hoverBackgroundColor ?? "#106EBE",
borderColor:this.props.hoverBorderColor ?? "#106EBE",
color:this.props.hoverColor ?? "#FFFFFF"
color:this.props.hoverColor ?? "#FFFFFF",
width:this.props.style?.width
},
rootPressed:{
backgroundColor:this.props.checkedBackgroundColor ?? "#0078d4",
borderColor:this.props.checkedBorderColor ?? "#0078d4",
color:this.props.checkedColor ?? "#FFFFFF"
color:this.props.checkedColor ?? "#FFFFFF",
width:this.props.style?.width
}
}

icon : IIconProps = {iconName : this.props.iconName ?? ""};

render(){
if(this.props.text?.trim().length ?? 0 > 0)
return(
<Stack horizontal>
<PrimaryButton iconProps={this.icon} styles={this.styles} text={this.props.text} disabled={this.props.disabled} onClick={this.props.onClick}/>
</Stack>
);
else return(

<Stack horizontal>
<IconButton iconProps={this.icon} styles={this.styles} disabled={this.props.disabled} onClick={this.props.onClick}/>
</Stack>
);
}
}

1 change: 1 addition & 0 deletions ActionButton/ActionButton/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<value name="IdChoice" display-name-key="IdChoice_Display_Key" description-key="IdChoice_Desc_Key">1</value>
<value name="LabelChoice" display-name-key="LabelChoice_Display_Key" description-key="LabelChoice_Desc_Key">0</value>
</property>
<property name="Width" display-name-key="Width_Display_Key" description-key="Width_Desc_Key" of-type="SingleLine.Text" default-value="" usage="input" required="false" />
<property name="EnableButtonOnDisabledForm" display-name-key="EnableButtonOnDisabledForm_Display_Key" description-key="EnableButtonOnDisabledForm_Desc_Key" of-type="Enum" default-value="1" usage="input" required="true">
<value name="Yes" display-name-key="yes_Display_Key" description-key="yes_Desc_Key">1</value>
<value name="No" display-name-key="no_Display_Key" description-key="no_Desc_Key">0</value>
Expand Down
8 changes: 5 additions & 3 deletions ActionButton/ActionButton/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export class ActionButton implements ComponentFramework.StandardControl<IInputs,
this.actionText = context.parameters.ActionText.raw??"";
this.id = context.parameters.Id.raw??"";
this.sendId = context.parameters.SendId.raw === "1";
this.controlType = context.parameters.BoundAttribute.type;

// @ts-ignore
this.controlType = context.parameters.BoundAttribute.attributes.Type;

if(this.actionText.trim().startsWith("{")){
let json = JSON.parse(this.actionText);
Expand All @@ -66,6 +68,7 @@ export class ActionButton implements ComponentFramework.StandardControl<IInputs,
backgroundColor: context.parameters.BackColor.raw ?? "#0078d4",
borderColor: context.parameters.BorderColor.raw ?? "#0078d4",
color: context.parameters.Color.raw ?? "#FFFFFF",
width: context.parameters.Width.raw ?? "auto"
},
hoverBackgroundColor: context.parameters.HoverBackColor.raw ?? "#106EBE",
hoverBorderColor: context.parameters.HoverBorderColor.raw ?? "#106EBE",
Expand Down Expand Up @@ -98,8 +101,7 @@ export class ActionButton implements ComponentFramework.StandardControl<IInputs,
*/
public getOutputs(): IOutputs
{
debugger;
if(this.controlType === "SingleLine.Text"){
if(this.controlType === "string"){
return {
BoundAttribute: this.sendId ? this.id : this.actionText
};
Expand Down
3 changes: 3 additions & 0 deletions ActionButton/ActionButton/strings/ActionButton.1033.resx
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,8 @@
<data name="PressedColor_Desc_Key" xml:space="preserve">
<value>Text color when the mouse clicks the button</value>
</data>
<data name="Width_Display_Key" xml:space="preserve">
<value>Width</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</root>
3 changes: 3 additions & 0 deletions ActionButton/ActionButton/strings/ActionButton.1036.resx
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,8 @@
<data name="PressedColor_Desc_Key" xml:space="preserve">
<value>Couleur de texte du bouton lors du clic de la souris</value>
</data>
<data name="Width_Display_Key" xml:space="preserve">
<value>Largeur</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</root>

0 comments on commit ae8960f

Please sign in to comment.