Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
see #1672 This PR creates reusable slider nav (navigation between sentences in text2text)
- Loading branch information
Showing
4 changed files
with
139 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<!-- | ||
- coding=utf-8 | ||
- Copyright 2021-present, the Recognai S.L. team. | ||
- | ||
- Licensed under the Apache License, Version 2.0 (the "License"); | ||
- you may not use this file except in compliance with the License. | ||
- You may obtain a copy of the License at | ||
- | ||
- http://www.apache.org/licenses/LICENSE-2.0 | ||
- | ||
- Unless required by applicable law or agreed to in writing, software | ||
- distributed under the License is distributed on an "AS IS" BASIS, | ||
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
- See the License for the specific language governing permissions and | ||
- limitations under the License. | ||
--> | ||
|
||
<template> | ||
<div class="slides-nav"> | ||
<a | ||
:class="itemNumber <= 0 ? 'disabled' : null" | ||
href="#" | ||
@click.prevent="prev(itemNumber)" | ||
> | ||
<svgicon name="chevron-left" width="8" height="8" color="#4C4EA3" /> | ||
</a> | ||
{{ itemNumber + 1 }} of {{ slidesOrigin.length }} {{ slidesName }} | ||
<a | ||
:class="slidesOrigin.length <= itemNumber + 1 ? 'disabled' : null" | ||
href="#" | ||
@click.prevent="next(itemNumber)" | ||
> | ||
<svgicon name="chevron-right" width="8" height="8" color="#4C4EA3" /> | ||
</a> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
itemNumber: { | ||
type: Number, | ||
required: true, | ||
}, | ||
slidesName: { | ||
type: String, | ||
required: true, | ||
}, | ||
slidesOrigin: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
methods: { | ||
prev(number) { | ||
this.$emit("go-to", --number); | ||
}, | ||
next(number) { | ||
this.$emit("go-to", ++number); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.slides-nav { | ||
@include font-size(13px); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
min-width: 33%; | ||
margin-right: auto; | ||
margin-left: 0; | ||
color: $font-medium; | ||
a { | ||
height: 20px; | ||
width: 20px; | ||
line-height: 19px; | ||
text-align: center; | ||
border-radius: 3px; | ||
text-align: center; | ||
margin-left: 1.5em; | ||
margin-right: 1.5em; | ||
display: inline-block; | ||
text-decoration: none; | ||
outline: none; | ||
@include font-size(13px); | ||
background: transparent; | ||
transition: all 0.2s ease-in-out; | ||
&:hover { | ||
background: palette(grey, 800); | ||
transition: all 0.2s ease-in-out; | ||
} | ||
&.disabled { | ||
opacity: 0; | ||
pointer-events: none; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { mount } from "@vue/test-utils"; | ||
import BaseSlider from "@/components/core/BaseSlider"; | ||
|
||
function mountBaseSlider() { | ||
return mount(BaseSlider, { | ||
propsData: { | ||
slidesName: "sentences", | ||
slidesOrigin: ["first sentence", "second sentence"], | ||
itemNumber: 0, | ||
}, | ||
}); | ||
} | ||
|
||
describe("BaseSlider", () => { | ||
let spy = jest.spyOn(console, "error"); | ||
afterEach(() => spy.mockReset()); | ||
|
||
test("renders properly", () => { | ||
const wrapper = mountBaseSlider(); | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
frontend/specs/components/core/__snapshots__/BaseSlider.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`BaseSlider renders properly 1`] = ` | ||
<div class="slides-nav"><a href="#" class="disabled"><svg version="1.1" viewBox="0 0 8 8" class="svg-icon svg-fill" style="width: 8px; height: 8px;"></svg></a> | ||
1 of 2 sentences | ||
<a href="#"><svg version="1.1" viewBox="0 0 8 8" class="svg-icon svg-fill" style="width: 8px; height: 8px;"></svg></a> | ||
</div> | ||
`; |