Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
fix: fixed checkboxes, toggles, list groups, linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianKienle committed Jul 16, 2019
1 parent 0737367 commit dbd3af5
Show file tree
Hide file tree
Showing 187 changed files with 752 additions and 1,358 deletions.
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"htmlWhitespaceSensitivity": "ignore",
"printWidth": 100
}
29 changes: 9 additions & 20 deletions demo/pages/menu-selection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,24 @@
:selectedUid.sync="selectedUid"
>
<fd-menu-list>
<fd-menu-item data-cy-item-a-0 uid="a-id-0" value="a-value-0"
>a-title-0</fd-menu-item
>
<fd-menu-item data-cy-item-a-1 uid="a-id-1" value="a-value-1"
>a-title-1</fd-menu-item
>
<fd-menu-item data-cy-item-a-2 uid="a-id-2" value="a-value-2"
>a-title-2</fd-menu-item
>
<fd-menu-item data-cy-item-a-0 uid="a-id-0" value="a-value-0">a-title-0</fd-menu-item>
<fd-menu-item data-cy-item-a-1 uid="a-id-1" value="a-value-1">a-title-1</fd-menu-item>
<fd-menu-item data-cy-item-a-2 uid="a-id-2" value="a-value-2">a-title-2</fd-menu-item>
</fd-menu-list>
</fd-menu>
<p>
highlightedUid: <span data-highlighted-uid>{{ highlightedUid }}</span>
highlightedUid:
<span data-highlighted-uid>{{ highlightedUid }}</span>
</p>
<p>
selectedUid: <span data-selected-uid>{{ selectedUid }}</span>
selectedUid:
<span data-selected-uid>{{ selectedUid }}</span>
</p>
<label>
Highlight Uid:
<input
data-cy-uid-to-highlight
type="text"
v-model="uidToBeHighlighted"
/>
<input data-cy-uid-to-highlight type="text" v-model="uidToBeHighlighted" />
</label>
<button
data-cy-perform-highlight
@click="highlightedUid = uidToBeHighlighted"
>
<button data-cy-perform-highlight @click="highlightedUid = uidToBeHighlighted">
Highlight
</button>
</div>
Expand Down
4 changes: 1 addition & 3 deletions demo/pages/virtualized-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
<div data-cy-loading-indicator>Loading Indicator</div>
</template>
<template #item="{ item, index }">
<div data-cy-item style="height: 30px;">
{{ item.title }}[{{ index }}]
</div>
<div data-cy-item style="height: 30px;">{{ item.title }}[{{ index }}]</div>
</template>
</fd-virtualized-list>
</div>
Expand Down
8 changes: 1 addition & 7 deletions loaders/remove-docs-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ const contentWithoutBlock = (content, block) => {
};

module.exports = content => {
const blocksToRemove = [
"condensed",
"fullscreen-only",
"docs",
"title",
"tip"
];
const blocksToRemove = ["condensed", "fullscreen-only", "docs", "title", "tip"];
const result = blocksToRemove
.reduce((prev, curr) => contentWithoutBlock(prev, curr), content)
.trim();
Expand Down
3 changes: 1 addition & 2 deletions src/components/$Support/on-click-outside.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// @ts-check
<script>
// Thanks @LinusBorg
const isBrowser =
typeof window !== "undefined" && typeof document !== undefined;
const isBrowser = typeof window !== "undefined" && typeof document !== undefined;
const getRootEl = () => document.documentElement;
const CLICK_OUTSIDE_EVENT = "do";
Expand Down
8 changes: 2 additions & 6 deletions src/components/ActionBar/__tests__/ActionBar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ describe("ActionBar", () => {

it("renders correct props and slots", () => {
expect(wrapper.find(".fd-action-bar__title").text()).toEqual(title);
expect(wrapper.find(".fd-action-bar__description").text()).toEqual(
description
);
expect(wrapper.find(".fd-action-bar__description").text()).toEqual(description);
expect(wrapper.find(".fd-action-bar__back").text()).toEqual(back);
expect(wrapper.find(".fd-action-bar__actions").text()).toEqual(actions);
});
Expand Down Expand Up @@ -89,9 +87,7 @@ describe("ActionBar", () => {
});

it("renders title as slot", () => {
expect(wrapper.find(".fd-action-bar__description div").text()).toBe(
description
);
expect(wrapper.find(".fd-action-bar__description div").text()).toBe(description);
});
});
});
6 changes: 1 addition & 5 deletions src/components/Alert/Alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ export default {
type: String,
default: "default",
validator: value => {
return (
["default", "warning", "error", "information", "success"].indexOf(
value
) >= 0
);
return ["default", "warning", "error", "information", "success"].indexOf(value) >= 0;
}
}
},
Expand Down
3 changes: 1 addition & 2 deletions src/components/Badge/Badge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export default {
},
computed: {
classes() {
const type =
this.type == null ? {} : { [`fd-badge--${this.type}`]: true };
const type = this.type == null ? {} : { [`fd-badge--${this.type}`]: true };
return {
"fd-badge": true,
"fd-badge--filled": this.filled,
Expand Down
7 changes: 1 addition & 6 deletions src/components/BreadcrumbItem/BreadcrumbItem.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<template>
<li class="fd-breadcrumb__item">
<a
class="fd-breadcrumb__link"
@click="pushLocationIfPossible"
v-bind="attrs"
v-on="$listeners"
>
<a class="fd-breadcrumb__link" @click="pushLocationIfPossible" v-bind="attrs" v-on="$listeners">
<!-- Anchor tag content -->
<slot />
</a>
Expand Down
4 changes: 1 addition & 3 deletions src/components/Calendar/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ export default {
return this.normalizedDate_.end;
},
yearPickerYears() {
return Array.from({ length: 12 }).map(
(_, index) => this.displayedYear + (index - 6)
);
return Array.from({ length: 12 }).map((_, index) => this.displayedYear + (index - 6));
},
currentRange() {
const month = this.month;
Expand Down
3 changes: 2 additions & 1 deletion src/components/Calendar/CalendarAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
:state="state"
:icon="icon"
@click="$emit('click')"
>{{ title }}</FdButton
>
{{ title }}
</FdButton>
</div>
</template>

Expand Down
7 changes: 2 additions & 5 deletions src/components/Calendar/CalendarItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,13 @@ export default {
computed: {
classes() {
const state = this.state;
const isFirstOrLast =
state === "selectedRangeFirst" || state === "selectedRangeLast";
const isFirstOrLast = state === "selectedRangeFirst" || state === "selectedRangeLast";
const stateClasses = [
...(isFirstOrLast ? [calendarItemStateMapping.selected] : []),
...(state != null ? [calendarItemStateMapping[state]] : [])
];
const modifier = this.modifier;
return stateClasses.concat(
modifier == null ? [] : calendarItemModifierMapping[modifier]
);
return stateClasses.concat(modifier == null ? [] : calendarItemModifierMapping[modifier]);
}
},
render(h) {
Expand Down
15 changes: 3 additions & 12 deletions src/components/Calendar/Pickers/DayPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@
<table class="fd-calendar__table" role="grid">
<thead class="fd-calendar__group">
<tr class="fd-calendar__row">
<th
v-for="dayName in dayNames"
:key="dayName"
class="fd-calendar__column-header"
>
<th v-for="dayName in dayNames" :key="dayName" class="fd-calendar__column-header">
<span class="fd-calendar__day-of-week">{{ dayName }}</span>
</th>
</tr>
</thead>
<tbody class="fd-calendar__group">
<tr
class="fd-calendar__row"
v-for="(week, index) in month"
:key="String('week-' + index)"
>
<tr class="fd-calendar__row" v-for="(week, index) in month" :key="String('week-' + index)">
<CalendarItem
v-for="date in week"
:key="date.toString()"
Expand Down Expand Up @@ -79,8 +71,7 @@ export default {
return "blocked";
}
const { selectionStart, selectionEnd } = this;
const isFirst =
selectionStart != null ? sameDay(date, selectionStart) : false;
const isFirst = selectionStart != null ? sameDay(date, selectionStart) : false;
const isLast = selectionEnd != null ? sameDay(date, selectionEnd) : false;
const isFirstAndLast = isFirst && (isLast || this.mode === Mode.single);
if (isFirstAndLast) {
Expand Down
3 changes: 1 addition & 2 deletions src/components/Calendar/mixins/DisplayedDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export default {
data() {
return {
displayedDate:
typeof this.defaultValue === "string" ||
typeof this.defaultValue === "number"
typeof this.defaultValue === "string" || typeof this.defaultValue === "number"
? new Date(this.defaultValue)
: this.defaultValue
};
Expand Down
10 changes: 2 additions & 8 deletions src/components/Calendar/util/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// @ts-check

export const weekFromDate = (
date,
{ firstDayOfWeek } = { firstDayOfWeek: 0 }
) => {
export const weekFromDate = (date, { firstDayOfWeek } = { firstDayOfWeek: 0 }) => {
const startOfWeek = new Date(date.valueOf());
startOfWeek.setDate(date.getDate() - date.getDay() + firstDayOfWeek);

Expand All @@ -21,10 +18,7 @@ export const weekFromDate = (
return days;
};

export const monthFromDate = (
referenceDate,
options = { firstDayOfWeek: 0 }
) => {
export const monthFromDate = (referenceDate, options = { firstDayOfWeek: 0 }) => {
const month = referenceDate.getMonth();
const result = [];
const firstDayOfMonth = new Date(referenceDate.getFullYear(), month, 1);
Expand Down
12 changes: 2 additions & 10 deletions src/components/ComboboxBase/ComboboxBase.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
<template>
<fd-popover
ref="popover"
body-size-mode="equal-trigger"
placement="bottom-start"
>
<fd-popover ref="popover" body-size-mode="equal-trigger" placement="bottom-start">
<template #control="{ hide, show, toggle }">
<div class="fd-combobox-control">
<fd-input-group :compact="compact">
<template #input>
<slot
name="input"
:hideCompletions="hide"
:showCompletions="show"
/>
<slot name="input" :hideCompletions="hide" :showCompletions="show" />
</template>

<template #after>
Expand Down
16 changes: 3 additions & 13 deletions src/components/DateInput/DateInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,11 @@ export default {
computed: {
displayedValue: {
get() {
const {
mode,
normalizedDate,
dateFormatter,
dateRangeFormatter
} = this;
const { mode, normalizedDate, dateFormatter, dateRangeFormatter } = this;
if (mode === "single") {
return dateFormatter(NormalizedDate.from(normalizedDate).start);
}
return dateRangeFormatter(
NormalizedDate.from(normalizedDate).asStartEndValue()
);
return dateRangeFormatter(NormalizedDate.from(normalizedDate).asStartEndValue());
},
set(newDateString) {
const { mode, dateParser, dateRangeParser, normalizedDate } = this;
Expand Down Expand Up @@ -67,10 +60,7 @@ export default {
emitCurrentValue() {
// Emitted whenever the date or range has been confirmed by the user.
// @arg An object with two keys: `from` and `to` – both can be either `null` or `Date`. In `single`-mode only `from` will be a `Date`.
this.$emit(
"input",
NormalizedDate.from(this.normalizedDate).asFromToValue()
);
this.$emit("input", NormalizedDate.from(this.normalizedDate).asFromToValue());
},
dateInputChanged(inputString) {
this.displayedValue = inputString;
Expand Down
4 changes: 1 addition & 3 deletions src/components/DropdownControl/DropdownControl.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<template>
<fd-button class="fd-dropdown__control" v-on="$listeners" v-bind="$attrs"
><slot
/></fd-button>
<fd-button class="fd-dropdown__control" v-on="$listeners" v-bind="$attrs"><slot /></fd-button>
</template>

<script>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Form/Controls/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
v-on="$listeners"
:value="value"
type="checkbox"
v-bind="$attrs"
:id="inputId"
/>
</template>

<script>
// v-bind="$attrs" -->
// :id="inputId"
import { isInputElement } from "./Helper";
import { withoutDuplicates } from "./../../../util";
import InputMixin from "./InputMixin";
Expand All @@ -21,7 +21,7 @@ import { $modelValueWithDefault, $valueWithDefault } from "./Helper/prop";
export default {
name: "FdCheckbox",
mixins: [InputMixin],
inheritAttrs: true,
// inheritAttrs: true,
inject: {
// We need the form item so that we can say tell the form item
// to render the checked-style
Expand Down
3 changes: 1 addition & 2 deletions src/components/Form/Controls/Helper/dom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export const isElement = target => "tagName" in target;
export const isInputElement = target =>
isElement(target) && target.tagName === "INPUT";
export const isInputElement = target => isElement(target) && target.tagName === "INPUT";
3 changes: 1 addition & 2 deletions src/components/Form/Controls/Toggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
:value="value"
:disabled="disabled"
@update="$emit('update', $event)"
>
</FdCheckbox>
></FdCheckbox>
<span class="fd-toggle__switch" role="presentation" />
</span>
</template>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Form/FormLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<label class="fd-form__label" :for="itemId" :aria-required="String(required)">
<slot name="control" />
<slot />
<template v-if="required"
>*</template
>
<template v-if="required">
*
</template>
</label>
</template>

Expand Down
7 changes: 5 additions & 2 deletions src/components/Form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as Controls from "./Controls";
import { pluginify } from "./../../util";
import FdFormItemRadio from "./items/form-item-radio.vue";
import FdFormItemCheckbox from "./items/form-item-checkbox.vue";
import FdFormItemToggle from "./items/form-item-toggle.vue";

export default pluginify(
Form,
Expand All @@ -31,7 +32,8 @@ export default pluginify(
Legend,
FieldSet,
FdFormItemRadio,
FdFormItemCheckbox
FdFormItemCheckbox,
FdFormItemToggle
);
export {
Form,
Expand All @@ -49,5 +51,6 @@ export {
FieldSet,
Controls,
FdFormItemRadio,
FdFormItemCheckbox
FdFormItemCheckbox,
FdFormItemToggle
};
Loading

0 comments on commit dbd3af5

Please sign in to comment.