Skip to content

Commit 64cd421

Browse files
committed
Create a common component for License Copy component
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent b94efe6 commit 64cd421

File tree

3 files changed

+48
-226
lines changed

3 files changed

+48
-226
lines changed

src/App.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<Stepper v-model="currentStepId" />
2121
<div class="column">
2222
<div class="fixed-right-column">
23-
<SelectedLicenseCard
23+
<LicenseDetailsCard
2424
v-if="showLicense"
2525
/>
2626
<LicenseUseCard
@@ -42,18 +42,18 @@ import '@creativecommons/vocabulary/css/index.css'
4242
4343
import HelpSection from './components/HelpSection'
4444
import Stepper from './components/Stepper'
45-
import SelectedLicenseCard from './components/LicenseDetailsCard'
4645
import LicenseUseCard from './components/LicenseUseCard'
4746
import Header from './components/Header.vue'
4847
import Footer from './components/Footer'
4948
import LocaleChooser from './components/LocaleChooser'
49+
import LicenseDetailsCard from './components/LicenseDetailsCard'
5050
5151
export default {
5252
name: 'App',
5353
components: {
5454
HelpSection,
5555
Stepper,
56-
SelectedLicenseCard,
56+
LicenseDetailsCard,
5757
LicenseUseCard,
5858
Header,
5959
Footer,

src/components/WebLicenseCode.vue renamed to src/components/LicenseCopy.vue

+45-43
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
v-model="activeTab"
55
class="attribution-tab"
66
>
7-
<b-tab-item :label="this.$t('license-use.rich-text-label')">
8-
<div id="attribution-richtext">
9-
<LicenseCode ref="licenseCode" />
7+
<b-tab-item :label="this.$t(firstTabLabel)">
8+
<div id="attribution-text">
9+
<LicenseCode
10+
:attribution-type="textAttributionType"
11+
/>
1012
</div>
1113
</b-tab-item>
12-
<b-tab-item :label="this.$t('license-use.html-label')">
14+
<b-tab-item
15+
v-if="isWeb"
16+
:label="this.$t('license-use.html-label')"
17+
>
1318
<div
1419
id="generated-html-container"
1520
class="control"
@@ -29,8 +34,7 @@
2934
:data-clipboard-target="clipboardTarget()"
3035
>
3136
<font-awesome-icon icon="copy" />
32-
<span class="button-text">{{ copyText }}
33-
</span>
37+
<span class="button-text">{{ copyText }}</span>
3438
</a>
3539
</template>
3640
<div class="dummy" />
@@ -42,32 +46,44 @@
4246
import Clipboard from 'clipboard'
4347
import { mapGetters } from 'vuex'
4448
import LicenseCode from './LicenseCode'
45-
import { generateHTML } from '../utils/license-utilities'
4649
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
50+
import { generateHTML } from '../utils/license-utilities'
4751
4852
export default {
49-
name: 'WebLicenseCode',
53+
name: 'LicenseCopy',
5054
components: {
5155
FontAwesomeIcon,
5256
LicenseCode
5357
},
5458
props: {
55-
value: Object
59+
isWeb: {
60+
type: Boolean,
61+
default: true
62+
}
5663
},
5764
data() {
5865
return {
5966
success: false,
6067
clipboard: null,
6168
currentTab: 0,
6269
copyText: this.$t('license-use.copy-label'),
63-
currentSelection: 'richtext'
70+
currentSelection: 'text'
6471
}
6572
},
6673
computed: {
6774
...mapGetters(['shortName', 'fullName', 'iconsList', 'licenseUrl']),
6875
attributionDetails() {
6976
return this.$store.state.attributionDetails
7077
},
78+
tabsCount() {
79+
return this.isWeb ? 2 : 1
80+
},
81+
firstTabLabel() {
82+
return this.isWeb ? 'license-use.rich-text-label' : 'license-use.plain-text-label'
83+
},
84+
textAttributionType() {
85+
return this.isWeb ? 'web' : 'print'
86+
},
7187
htmlLicenseParagraph() {
7288
const data = generateHTML(this.attributionDetails, this.shortName)
7389
const licenseCodeSpan = this.$i18n.t('license-use.richtext.full-text', {
@@ -81,12 +97,12 @@ export default {
8197
activeTab: {
8298
get() { return this.currentTab },
8399
set(val) {
84-
if (val !== 2) {
100+
if (val !== this.tabsCount) {
85101
this.currentTab = val
86102
} else {
87-
this.currentSelection = this.currentTab === 0 ? 'richtext' : 'html'
103+
this.currentSelection = this.currentTab === 0 ? 'text' : 'html'
88104
const tab = this.currentTab
89-
this.currentTab = 2
105+
this.currentTab = this.tabsCount
90106
this.copyText = this.$t('license-use.copied-label')
91107
setTimeout(() => {
92108
this.currentTab = tab
@@ -117,7 +133,7 @@ export default {
117133
const copiedLicense = {
118134
license: this.shortName,
119135
// codeType can be either rich-text or html
120-
codeType: this.currentSelection,
136+
codeType: 'plaintext',
121137
fieldsFilled: fieldsFilled
122138
}
123139
this.$ga.event({
@@ -143,20 +159,29 @@ export default {
143159
}
144160
</script>
145161
<style lang="scss">
146-
147162
.copyBtn svg {
148163
margin-right: 3px;
149164
}
150165
151-
#attribution-richtext>p>span,
152-
#attribution-richtext .photo-license-icons{
153-
height: 26px;
154-
vertical-align: middle;
166+
.attribution-tab .photo-license-icon {
167+
height: 1.4rem;
155168
}
156-
#attribution-richtext p {
169+
170+
#attribution-text p {
157171
margin-top: 0.5rem;
158172
margin-bottom: 1rem;
159173
}
174+
#generated-html-container {
175+
padding-top: 10px;
176+
padding-bottom: 10px;
177+
}
178+
#generated-html-container textarea {
179+
word-break: break-all;
180+
-ms-word-break: break-all;
181+
min-height: 60px;
182+
font-family: Source Sans Pro, Noto Sans, Arial, Helvetica Neue, Helvetica, sans-serif;
183+
font-size: .845rem;
184+
}
160185
.license-use-hint {
161186
text-align: center;
162187
}
@@ -205,27 +230,4 @@ export default {
205230
}
206231
}
207232
}
208-
#generated-html-container {
209-
padding-top:10px;
210-
padding-bottom: 10px;
211-
textarea {
212-
word-break: break-all;
213-
-ms-word-break: break-all;
214-
min-height: 60px;
215-
font-family: "Source Sans Pro", "Noto Sans", Arial, "Helvetica Neue", Helvetica, sans-serif;
216-
font-size:0.845rem;
217-
}
218-
}
219-
#generated-richtext-container {
220-
margin-top: 1rem;
221-
display: block;
222-
.attribution-license-icons {
223-
vertical-align: middle;
224-
margin-top: 0;
225-
margin-left: 2px;
226-
}
227-
p {
228-
display: inline
229-
}
230-
}
231233
</style>

src/components/PrintMediaLicenseCode.vue

-180
This file was deleted.

0 commit comments

Comments
 (0)