Skip to content

Commit

Permalink
Merge 250f644 into 36a451a
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-dantas committed Aug 29, 2018
2 parents 36a451a + 250f644 commit 9a5e8df
Show file tree
Hide file tree
Showing 14 changed files with 479 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bh/assets/scss/bh.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
@import '~./typography';
@import '~./forms';
@import '~./utils';
@import '~./shadow';
20 changes: 20 additions & 0 deletions src/bh/assets/scss/shadow.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$shadow-color: rgba(0, 0, 0, 0.5);

@mixin shadow() {

&--shaded {
box-shadow: .25rem .25rem .5rem -.25rem $shadow-color;

&-light {
box-shadow: .125rem .125rem .25rem -.125rem $shadow-color;
}

&-strong {
box-shadow: .25rem .25rem .75rem -.25rem $shadow-color;
}

&-hard {
box-shadow: .25rem .25rem 1rem -.25rem $shadow-color;
}
}
}
8 changes: 8 additions & 0 deletions src/bh/assets/scss/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ $form-component-height-large: $height-large;
$tooltip-z-index: 10;
$dropdown-z-index: 9;
$autocomplete-z-index: 8;


// Radius

$radius-normal: .5rem;
$radius-small: .25rem;
$radius-medium: .75rem;
$radius-large: 1rem;
56 changes: 56 additions & 0 deletions src/bh/components/BhCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<div
:class="[
'bh-card',
!!shadow
? `bh-card--shaded-${shadow}`
: 'bh-card--shaded'
]">
<div class="bh-card__main">
<slot />
</div>
<div
v-if="$slots.append"
class="bh-card__append">
<slot name="append"/>
</div>
</div>
</template>

<script>
export default {
name: 'BhCard',
props: {
shadow: {
type: String,
default: null,
},
},
};
</script>

<style lang="scss">
@import '~bh/assets/scss/colors.scss';
@import '~bh/assets/scss/variables.scss';
@import '~bh/assets/scss/shadow.scss';
.bh {
&-card {
@include shadow();
display: flex;
flex-direction: row;
border: 1px solid $color-lighter-grey;
border-radius: $radius-normal;
&__main {
flex-grow: 1;
}
&__append {
flex-grow: 0;
}
}
}
</style>
2 changes: 2 additions & 0 deletions src/bh/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import BhDropdownItem from './components/BhDropdownItem';
import BhLanguageFlag from './components/BhLanguageFlag';
import BhAutocomplete from './components/BhAutocomplete';
import BhInput from './components/BhInput';
import BhCard from './components/BhCard';


const components = [
Expand All @@ -29,6 +30,7 @@ const components = [
BhLanguageFlag,
BhAutocomplete,
BhInput,
BhCard,
];

export default {
Expand Down
5 changes: 5 additions & 0 deletions src/components/Repository.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
</div>
</div>
</div>
<intents-and-labels-list
:labels="repository.labels"
:intents="repository.intents" />
<h1 class="title examples-title">Examples</h1>
<examples-list
ref="examplesList"
Expand Down Expand Up @@ -434,6 +437,7 @@ import SetAuthorizationRoleForm from '@/components/repository/SetAuthorizationRo
import AuthorizationsList from '@/components/repository/AuthorizationsList';
import RequestAuthorizationForm from '@/components/repository/RequestAuthorizationForm';
import AuthorizationRequestsList from '@/components/repository/AuthorizationRequestsList';
import IntentsAndLabelsList from '@/components/repository/IntentsAndLabelsList';
const components = {
Expand All @@ -455,6 +459,7 @@ const components = {
AuthorizationsList,
RequestAuthorizationForm,
AuthorizationRequestsList,
IntentsAndLabelsList,
};
export default {
Expand Down
104 changes: 104 additions & 0 deletions src/components/repository/IntentsAndLabelsItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<template>
<bh-card>
<div class="i-a-l-item">
<div class="i-a-l-item__left">
<div class="i-a-l-item__left__content">
<strong>{{ title }}</strong>
<div class="i-a-l-item__left__content__info">
<span><strong>{{ 0 }}</strong> Sentences</span>
<span v-if="labelEntities"><strong>{{ 0 }}</strong> Entities</span>
</div>
</div>
<span v-if="labelEntities">Entities</span>
</div>
<div
v-if="labelEntities"
slot="append"
class="entities">
<bh-badge
v-for="(entities, i) in labelEntities"
:key="i"
:class="[
'entities__entity',
getEntityClass(entities),
]"
size="small">
<span>{{ entities }}</span>
</bh-badge>
</div>
</div>
</bh-card>
</template>

<script>
import { getEntityColor } from '@/utils/entitiesColors';
export default {
name: 'IntentsAndLabelsItem',
props: {
title: {
type: String,
required: true,
},
labelEntities: {
type: Array,
default: null,
},
},
methods: {
getEntityClass(entity) {
const color = getEntityColor(
entity,
this.labelEntities,
);
return `entity-${color}`;
},
},
};
</script>

<style lang="scss" scoped>
@import '~bh/assets/scss/bh.scss';
.i-a-l-item {
flex-grow: 1;
display: flex;
color:$color-grey;
&__left {
display: flex;
flex-grow: 1;
align-items: center;
border-color: #ebebeb;
border-style: double;
border-width: 0px 2px 0px 0px;
height: auto;
padding: 20px 20px 20px 20px;
&__content {
display: flex;
flex-direction: column;
justify-content: space-between;
flex-grow: 1;
&__info {
display: flex;
flex-direction: row;
justify-content: space-between;
width: 30%;
margin-top: 20px;
}
}
}
}
.entities {
flex-basis: 30%;
&__entity {
margin: .25rem;
}
}
</style>
86 changes: 86 additions & 0 deletions src/components/repository/IntentsAndLabelsList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<template>
<div class="intents-and-labels-list">
<div class="intents-and-labels-list__radio">
<bh-button
ref="intents"
:primary="listActived === 'intents'"
class="intents-and-labels-list__radio__button"
size="medium"
@click="activeList('intents')" >
Intents
</bh-button>
<bh-button
ref="labels"
:primary="listActived === 'labels'"
class="intents-and-labels-list__radio__button"
size="medium"
@click="activeList('labels')">
Labels
</bh-button>
</div>
<div v-if="listActived === 'intents'">
<intents-and-labels-item
v-for="intent in intents"
:key="intent"
:title="intent"
class="intents-and-labels-list__item" />
</div>
<div v-else-if="listActived === 'labels'">
<intents-and-labels-item
v-for="label in labels"
:key="label.value"
:title="label.value"
:label-entities="label.entities"
class="intents-and-labels-list__item" />
</div>
</div>
</template>

<script>
import IntentsAndLabelsItem from '@/components/repository/IntentsAndLabelsItem';
export default {
name: 'IntentsAndLabelsList',
components: {
IntentsAndLabelsItem,
},
props: {
intents: {
type: Array,
required: true,
},
labels: {
type: Array,
required: true,
},
},
data() {
return {
listActived: 'intents',
};
},
methods: {
activeList(value) {
this.listActived = value;
},
},
};
</script>

<style lang="scss" scoped>
.intents-and-labels-list {
&__radio {
margin: 0 -.25rem;
display: flex;
&__button {
margin: .25rem;
}
}
&__item {
margin: 1rem 0;
}
}
</style>
38 changes: 38 additions & 0 deletions test/unit/specs/bh/BhCard.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { compileToFunctions } from 'vue-template-compiler';
import BH from 'bh';
import BhCard from 'bh/components/BhCard';


const localVue = createLocalVue();
localVue.use(BH);

const defaultSlotComponent = compileToFunctions('<div>default</div>');
const appendSlotComponent = compileToFunctions('<div>append</div>');

describe('BhCard.vue', () => {
let wrapper;
beforeEach(() => {
wrapper = shallowMount(BhCard, {
localVue,
slots: {
default: defaultSlotComponent,
append: appendSlotComponent,
},
});
});

test('renders correctly', () => {
expect(wrapper).toMatchSnapshot();
});

describe('set shadow hard', () => {
beforeEach(() => {
wrapper.setProps({ shadow: 'hard' });
});

test('renders correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
});
23 changes: 23 additions & 0 deletions test/unit/specs/bh/__snapshots__/BhCard.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`BhCard.vue renders correctly 1`] = `
<div class="bh-card bh-card--shaded">
<div class="bh-card__main">
<div>default</div>
</div>
<div class="bh-card__append">
<div>append</div>
</div>
</div>
`;

exports[`BhCard.vue set shadow hard renders correctly 1`] = `
<div class="bh-card bh-card--shaded-hard">
<div class="bh-card__main">
<div>default</div>
</div>
<div class="bh-card__append">
<div>append</div>
</div>
</div>
`;
Loading

0 comments on commit 9a5e8df

Please sign in to comment.