Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
Added Slider // Released Version 0.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
s-bauer committed Dec 30, 2018
1 parent f7269a7 commit faf106a
Show file tree
Hide file tree
Showing 7 changed files with 674 additions and 12 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ Take a look at the [Component Progress Issue](https://github.com/s-bauer/office-
- [Link](https://developer.microsoft.com/en-us/fabric#/components/link)
- Props: disabled, href
- Info: `<button>` or `<a>` is exposed, so all events and props can be used

- [Slider](https://developer.microsoft.com/en-us/fabric#/components/slider)
- Model: :value / @change
- Props: disabled, vertical, showValue, min, max, step, label

## CI / CD

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "office-vue-fabric",
"version": "0.1.7",
"version": "0.1.8",
"private": false,
"main": "dist/office-vue-fabric.umd.min.js",
"license": "MIT",
"keywords": [
"vue",
"vuejs",
Expand Down
49 changes: 39 additions & 10 deletions src/components/Overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ import {ImageFit} from "./Image/OfficeImage.types";
<div>
<OfficeCheckbox v-model="checkboxChecked" :disabled="disabled" label="Checkbox"
style="display: inline-block"/>
<OfficeLabel :disabled="disabled" style="display: inline-block; margin-left: 50px;">The checkbox is {{ checkboxChecked ? "checked" : "not checked"}}</OfficeLabel>
<OfficeLabel :disabled="disabled" style="display: inline-block; margin-left: 50px;">The checkbox is {{
checkboxChecked ? "checked" : "not checked"}}
</OfficeLabel>
</div>
</div>

<div class="card">
<h5>Buttons</h5>
<div>
<OfficeButton label="Default Button" :disabled="disabled" :checked="checked" style="margin: 5px;"/>
<OfficeButton label="Primary Button" :primary="true" :disabled="disabled" :checked="checked"
<OfficeButton @click="clicked" label="Default Button" :disabled="disabled" :checked="checked" style="margin: 5px;"/>
<OfficeButton @click="clicked" label="Primary Button" :primary="true" :disabled="disabled" :checked="checked"
style="margin: 5px;"/>
</div>
</div>
Expand Down Expand Up @@ -75,20 +77,37 @@ import {ImageFit} from "./Image/OfficeImage.types";

<div class="card">
<h5>Toggle</h5>
<OfficeToggle :disabled="disabled" label="Normal Toggle" onText="on" offText="off" v-model="toggleChecked"></OfficeToggle>
<OfficeLabel :disabled="disabled" :required="required">Toggle: {{ toggleChecked ? 'on' : 'off' }}</OfficeLabel>
<OfficeToggle :disabled="disabled" label="Normal Toggle" onText="on" offText="off"
v-model="toggleChecked"></OfficeToggle>
<OfficeLabel :disabled="disabled" :required="required">Toggle: {{ toggleChecked ? 'on' : 'off' }}
</OfficeLabel>
</div>

<div class="card">
<h5>Links</h5>
A Link to <OfficeLink href="https://google.com">Google</OfficeLink>
A Link to
<OfficeLink href="https://google.com">Google</OfficeLink>
<br>
Another link without href <OfficeLink @click="linkClicked">IS HERE</OfficeLink>
Another link without href
<OfficeLink @click="clicked">IS HERE</OfficeLink>
<br>
And a <OfficeLink disabled>Disabled Link!</OfficeLink>
And a
<OfficeLink disabled>Disabled Link!</OfficeLink>
</div>

<OfficeLabel style="margin-top: 30px">This is the demo page for <OfficeLink href="https://github.com/s-bauer/office-ui-fabric-vue">office-ui-fabric-vue</OfficeLink></OfficeLabel>
<div class="card">
<h5>Slider</h5>
<OfficeSlider :min="0" :max="10" v-model="sliderValue"></OfficeSlider>
<OfficeSlider :min="0" :max="10" v-model="sliderValue" showValue></OfficeSlider>
<OfficeSlider :min="0" :max="10" v-model="sliderValue" showValue disabled></OfficeSlider>
<OfficeSlider :min="0" :max="10" v-model="sliderValue" vertical showValue class="vertical-slider"></OfficeSlider>
<OfficeSlider :min="0" :max="10" v-model="sliderValue" vertical showValue disabled class="vertical-slider"></OfficeSlider>
<OfficeLabel>Value: {{sliderValue}}</OfficeLabel>
</div>

<OfficeLabel style="margin-top: 30px">This is the demo page for
<OfficeLink href="https://github.com/s-bauer/office-ui-fabric-vue">office-ui-fabric-vue</OfficeLink>
</OfficeLabel>
</div>
</template>

Expand All @@ -100,6 +119,7 @@ import {ImageFit} from "./Image/OfficeImage.types";
import OfficeImage from "@/components/Image/OfficeImage.vue";
import OfficeLabel from "@/components/Label/OfficeLabel.vue";
import OfficeLink from "@/components/Link/OfficeLink.vue";
import OfficeSlider from "@/components/Slider/OfficeSlider.vue";
import OfficeToggle from "@/components/Toggle/OfficeToggle.vue";
import {Component, Prop, Vue} from "vue-property-decorator";
Expand All @@ -109,6 +129,7 @@ import {ImageFit} from "./Image/OfficeImage.types";
@Component({
components: {
OfficeSlider,
OfficeLink,
OfficeToggle,
OfficeChoiceGroupOption,
Expand Down Expand Up @@ -138,7 +159,9 @@ import {ImageFit} from "./Image/OfficeImage.types";
private checkboxChecked: boolean = false;
private linkClicked() {
private sliderValue: number = 50;
private clicked() {
alert("clicked!");
}
}
Expand Down Expand Up @@ -171,4 +194,10 @@ import {ImageFit} from "./Image/OfficeImage.types";
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
}
.vertical-slider {
height: 150px;
display: inline-block;
width: 50px;
}
</style>
260 changes: 260 additions & 0 deletions src/components/Slider/OfficeSlider.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
import {IOfficeSliderStyleProps, IOfficeSliderStyles} from "@/components/Slider/OfficeSlider.types";
import {AnimationVariables, getFocusStyle, HighContrastSelector} from "@/styling";
import {getGlobalClassNames} from "@/styling/styles/getGlobalClassNames";
import {getRTL} from "@uifabric/merge-styles/lib/transforms/rtlifyRules";

const GlobalClassNames = {
root: "ms-Slider",
enabled: "ms-Slider-enabled",
disabled: "ms-Slider-disabled",
row: "ms-Slider-row",
column: "ms-Slider-column",
container: "ms-Slider-container",
slideBox: "ms-Slider-slideBox",
line: "ms-Slider-line",
thumb: "ms-Slider-thumb",
activeSection: "ms-Slider-active",
inactiveSection: "ms-Slider-inactive",
valueLabel: "ms-Slider-value",
showValue: "ms-Slider-showValue",
showTransitions: "ms-Slider-showTransitions"
};

export const getStyles = (props: IOfficeSliderStyleProps): IOfficeSliderStyles => {
const { className, titleLabelClassName, theme } = props;
const classNames = getGlobalClassNames(GlobalClassNames, theme);

const slideBoxActiveSectionStyles = !props.disabled && {
backgroundColor: theme.palette.themePrimary,
selectors: {
[HighContrastSelector]: {
backgroundColor: "Highlight"
}
}
};

const slideBoxInactiveSectionStyles = !props.disabled && {
backgroundColor: theme.palette.themeLight,
selectors: {
[HighContrastSelector]: {
borderColor: "Highlight"
}
}
};

const slideBoxActiveThumbStyles = !props.disabled && {
border: `2px solid ${theme.palette.themePrimary}`,
selectors: {
[HighContrastSelector]: {
borderColor: "Highlight"
}
}
};

return {
root: [
classNames.root,
theme.fonts.medium,
{
userSelect: "none"
},
props.vertical && {
marginRight: 8
},
...[!props.disabled ? classNames.enabled : undefined],
...[props.disabled ? classNames.disabled : undefined],
...[!props.vertical ? classNames.row : undefined],
...[props.vertical ? classNames.column : undefined],
className
],
titleLabel: [
{
padding: 0
},
titleLabelClassName
],
container: [
classNames.container,
{
display: "flex",
flexWrap: "nowrap",
alignItems: "center"
},
props.vertical && {
flexDirection: "column",
height: "100%",
textAlign: "center",
margin: "8px 0"
}
],
slideBox: [
classNames.slideBox,
getFocusStyle(theme),
{
background: "transparent",
border: "none",
flexGrow: 1,
lineHeight: 28,
display: "flex",
alignItems: "center",
selectors: {
":active $activeSection": slideBoxActiveSectionStyles,
":hover $activeSection": slideBoxActiveSectionStyles,
":active $inactiveSection": slideBoxInactiveSectionStyles,
":hover $inactiveSection": slideBoxInactiveSectionStyles,
":active $thumb": slideBoxActiveThumbStyles,
":hover $thumb": slideBoxActiveThumbStyles,
"$thumb": [
{
borderWidth: 2,
borderStyle: "solid",
borderColor: theme.palette.neutralSecondary,
borderRadius: 10,
boxSizing: "border-box",
background: theme.palette.white,
display: "block",
width: 16,
height: 16,
position: "absolute"
},
props.vertical
? {
left: -6,
margin: "0 auto",
transform: "translateY(8px)"
}
: {
top: -6,
transform: getRTL() ? "translateX(50%)" : "translateX(-50%)"
},
props.showTransitions && {
transition: `left ${AnimationVariables.durationValue3} ${AnimationVariables.easeFunction1}`
},
props.disabled && {
borderColor: theme.palette.neutralTertiaryAlt,
selectors: {
[HighContrastSelector]: {
borderColor: "GrayText"
}
}
}
]
}
},
props.vertical
? {
height: "100%",
width: 28,
padding: "8px 0" // Make room for thumb at bottom of line
}
: {
height: 28,
width: "auto",
padding: "0 8px" // Make room for thumb at ends of line
},
...[props.showValue ? classNames.showValue : undefined],
...[props.showTransitions ? classNames.showTransitions : undefined]
],
thumb: [classNames.thumb],
line: [
classNames.line,
{
display: "flex",
position: "relative",
selectors: {
$lineContainer: [
{
borderRadius: 4,
boxSizing: "border-box"
},
props.vertical
? {
width: 4,
height: "100%"
}
: {
height: 4,
width: "100%"
}
]
}
},
props.vertical
? {
height: "100%",
width: 4,
margin: "0 auto",
flexDirection: "column-reverse"
}
: {
width: "100%"
}
],
lineContainer: [{}],
activeSection: [
classNames.activeSection,
{
background: theme.palette.neutralSecondary,
selectors: {
[HighContrastSelector]: {
backgroundColor: "WindowText"
}
}
},
props.showTransitions && {
transition: `width ${AnimationVariables.durationValue3} ${AnimationVariables.easeFunction1}`
},
props.disabled && {
background: theme.palette.neutralTertiaryAlt,
selectors: {
[HighContrastSelector]: {
backgroundColor: "GrayText",
borderColor: "GrayText"
}
}
}
],
inactiveSection: [
classNames.inactiveSection,
{
background: theme.palette.neutralTertiaryAlt,
selectors: {
[HighContrastSelector]: {
border: "1px solid WindowText"
}
}
},
props.showTransitions && {
transition: `width ${AnimationVariables.durationValue3} ${AnimationVariables.easeFunction1}`
},
props.disabled && {
background: theme.palette.neutralLight,
selectors: {
[HighContrastSelector]: {
backgroundColor: "GrayText",
borderColor: "GrayText"
}
}
}
],
valueLabel: [
classNames.valueLabel,
{
flexShrink: 1,
width: 30,
lineHeight: "1" // using a string here meaning it's relative to the size of the font
},
props.vertical
? {
margin: "0 auto",
whiteSpace: "nowrap",
width: 40
}
: {
margin: "0 8px",
whiteSpace: "nowrap",
width: 40
}
]
};
};
Loading

0 comments on commit faf106a

Please sign in to comment.