Skip to content

Commit

Permalink
CSS issues (#29)
Browse files Browse the repository at this point in the history
* issue-27 fixed

* issue-28 fixed
  • Loading branch information
p3trur0 authored May 1, 2020
1 parent 19f8813 commit 8ea7880
Show file tree
Hide file tree
Showing 6 changed files with 282 additions and 275 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ _Country flags as a Vue Component_
<img src="https://github.com/P3trur0/vue-country-flag/blob/master/assets/logo.png?raw=true" alt="vue-country-flag"/>
</p>
<p align="center">
<img src="https://packagephobia.now.sh/[email protected].0" alt="Install size">
<img src="https://packagephobia.now.sh/[email protected].1" alt="Install size">
<img src="https://img.shields.io/badge/Vue.js%202-compatible-green.svg" alt="Vue.js 2 compatible">
<a href="https://www.npmjs.com/package/vue-country-flag"><img src="https://img.shields.io/badge/npm-2.0.0-blue.svg" alt="Version"></a>
<a href="https://www.npmjs.com/package/vue-country-flag"><img src="https://img.shields.io/badge/npm-2.0.1-blue.svg" alt="Version"></a>
<a href="https://www.npmjs.com/package/vue-country-flag"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
<img src="https://img.shields.io/badge/TypeScript-supported-blue" alt="TypeScript Supported">

Expand Down
25 changes: 15 additions & 10 deletions __tests__/CountryFlag.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ const convertToISOAlphaThree = (country) => {
return countriesMappings[country]
};

//see issue-27
const convertAndorraTwoDigitsToAndorra = (country) => {
return (country === 'ad') ? 'andorra' : country
}



describe('CountryFlag', () => {
Expand All @@ -296,44 +301,44 @@ describe('CountryFlag', () => {
const flag = shallowMount(CountryFlag, {
propsData: buildNormalFlag('it')
});
expect(flag.attributes('class')).toBe('f f-it normal-flag');
expect(flag.attributes('class')).toBe('flag f-it normal-flag');
})

test('big size of country-flag should return a big flag', () => {
const flag = shallowMount(CountryFlag, {
propsData: buildFlag('se', 'big')
});
expect(flag.attributes('class')).toBe('f f-se big-flag');
expect(flag.attributes('class')).toBe('flag f-se big-flag');
})

test("big size of rounded country-flag should return a rounded big flag", () => {
const flag = shallowMount(CountryFlag, {
propsData: buildFlag("se", "big", true)
});
expect(flag.attributes("class")).toBe(
"f f-se rounded big-flag"
"flag f-se rounded big-flag"
);
});

test('small size of country-flag should return a small flag', () => {
const flag = shallowMount(CountryFlag, {
propsData: buildFlag('se', 'small')
});
expect(flag.attributes('class')).toBe('f f-se small-flag');
expect(flag.attributes('class')).toBe('flag f-se small-flag');
})

test("normal size of country-flag should return a normal flag", () => {
const flag = shallowMount(CountryFlag, {
propsData: buildFlag("se", "normal")
});
expect(flag.attributes("class")).toBe("f f-se normal-flag");
expect(flag.attributes("class")).toBe("flag f-se normal-flag");
}),

test("[CAPITAL LETTER lowercase conversion] normal size of country-flag should return a normal flag", () => {
const flag = shallowMount(CountryFlag, {
propsData: buildFlag("SE", "normal")
});
expect(flag.attributes("class")).toBe("f f-se normal-flag");
expect(flag.attributes("class")).toBe("flag f-se normal-flag");
});
});

Expand All @@ -342,13 +347,13 @@ describe('CountryFlag', () => {
const flag = shallowMount(CountryFlag, {
propsData: buildNormalFlag(convertToISOAlphaThree('it'))
});
expect(flag.attributes('class')).toBe('f f-ita normal-flag');
expect(flag.attributes('class')).toBe('flag f-ita normal-flag');
})

test('it should map both two and three characters for all the countries', () => {
for (let country in countriesMappings) {
if (countriesMappings.hasOwnProperty(country)) {
let twoCharsIdentifier = country;
let twoCharsIdentifier = convertAndorraTwoDigitsToAndorra(country);
let threeCharsIdentifier = countriesMappings[country];

const flagTwo = shallowMount(CountryFlag, {
Expand All @@ -359,8 +364,8 @@ describe('CountryFlag', () => {
propsData: buildNormalFlag(threeCharsIdentifier)
});

expect(flagTwo.attributes('class')).toBe('f f-' + twoCharsIdentifier + ' normal-flag');
expect(flagThree.attributes('class')).toBe('f f-' + threeCharsIdentifier + ' normal-flag');
expect(flagTwo.attributes('class')).toBe('flag f-' + twoCharsIdentifier + ' normal-flag');
expect(flagThree.attributes('class')).toBe('flag f-' + threeCharsIdentifier + ' normal-flag');
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-country-flag",
"version": "2.0.0",
"version": "2.0.1",
"description": "Simple Vue component for displaying of country flags",
"main": "dist/country-flag.ssr.js",
"module": "dist/country-flag.esm.js",
Expand Down
6 changes: 4 additions & 2 deletions src/CountryFlag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ export default {
computed: {
flagIconClass () {
return {
[`f ${this.flagIconCountry}`]: true,
[`flag ${this.flagIconCountry}`]: true,
[`rounded`]: this.rounded,
[this.flagMargin]: true
}
},
flagIconCountry () {
return `f-${this.country.toLowerCase()}`
let country = this.country.toLowerCase()
country = (country === 'ad') ? 'andorra' : country
return `f-${country}`
},
flagMargin () {
switch (this.size) {
Expand Down
518 changes: 259 additions & 259 deletions src/css/flags/flags.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/css/flags/flags.min.css

Large diffs are not rendered by default.

0 comments on commit 8ea7880

Please sign in to comment.