Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
maximiliani committed Oct 31, 2024
1 parent a45e616 commit 60ce8d5
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 84 deletions.
5 changes: 3 additions & 2 deletions src/components/copy-button/copy-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class CopyButton {
textArea.select();
try {
const success = document.execCommand('copy');
console.log(`Deprecated Text copy was ${success ? 'successful' : 'unsuccessful'}.`);
console.debug(`Deprecated Text copy was ${success ? 'successful' : 'unsuccessful'}.`);
showSuccess();
} catch (err) {
console.error(err.name, err.message);
Expand All @@ -49,6 +49,8 @@ export class CopyButton {
el.classList.remove('hover:bg-blue-200');
el.classList.remove('bg-white');
el.classList.add('bg-green-200');

// Reset the button after 1.5 seconds.
setTimeout(() => {
el.classList.remove('bg-green-200');
el.classList.add('hover:bg-blue-200');
Expand All @@ -64,7 +66,6 @@ export class CopyButton {
class={
'bg-white border border-slate-500 text-slate-800 font-medium font-mono rounded-md px-2 py-0.5 hover:bg-blue-200 hover:text-slate-900 flex-none max-h-min items-center'
}
id={`copyButton-${this.value}`}
onClick={event => copyValue(event, this.value)}
>
Copy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const meta: Meta = {
},
args: {
locale: 'de-DE',
showFlag: true,
},
};
export default meta;
Expand Down
38 changes: 0 additions & 38 deletions src/index.html

This file was deleted.

1 change: 1 addition & 0 deletions src/rendererModules/Handle/HandleType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class HandleType extends GenericIdentifierType {
}

this.actions.push(new FoldableAction(0, 'Open in FAIR-DOscope', `https://kit-data-manager.github.io/fairdoscope/?pid=${this._pidRecord.pid.toString()}`, 'primary'));
this.actions.push(new FoldableAction(0, 'View in Handle.net registry', `https://hdl.handle.net/${this._pidRecord.pid.toString()}`, 'secondary'));

return;
}
Expand Down
17 changes: 2 additions & 15 deletions src/rendererModules/ORCiD/ORCIDType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { GenericIdentifierType } from '../../utils/GenericIdentifierType';
import { ORCIDInfo } from './ORCIDInfo';
import { FoldableItem } from '../../utils/FoldableItem';
import { FoldableAction } from '../../utils/FoldableAction';
import { getLocaleDetail } from '../../utils/utils';

/**
* This class specifies a custom renderer for ORCiDs.
Expand Down Expand Up @@ -145,18 +144,7 @@ export class ORCIDType extends GenericIdentifierType {
);

if (this._orcidInfo.preferredLocale)
this.items.push(
new FoldableItem(25, 'Preferred Language', this._orcidInfo.preferredLocale, 'The preferred locale/language of the person.'),
// new FoldableItem(
// 25,
// 'Preferred Language',
// getLocaleDetail(this._orcidInfo.preferredLocale, 'language'),
// 'The preferred locale/language of the person.',
// undefined,
// undefined,
// false,
// ),
);
this.items.push(new FoldableItem(25, 'Preferred Language', this._orcidInfo.preferredLocale, 'The preferred locale/language of the person.'));

for (const url of this._orcidInfo.researcherUrls) {
this.items.push(new FoldableItem(100, url.name, url.url, 'A link to a website specified by the person.'));
Expand All @@ -169,8 +157,7 @@ export class ORCIDType extends GenericIdentifierType {

if (this._orcidInfo.biography) this.items.push(new FoldableItem(200, 'Biography', this._orcidInfo.biography, 'The biography of the person.', undefined, undefined, false));

if (this._orcidInfo.country)
this.items.push(new FoldableItem(30, 'Country', getLocaleDetail(this._orcidInfo.country, 'region'), 'The country of the person.', undefined, undefined, false));
if (this._orcidInfo.country) this.items.push(new FoldableItem(30, 'Country', this._orcidInfo.country, 'The country of the person.'));
}
}

Expand Down
9 changes: 0 additions & 9 deletions src/utils/GenericIdentifierType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,6 @@ export abstract class GenericIdentifierType {
*/
abstract init(data?: any): Promise<void>;

/**
* This method indicates if a value is resolvable or not.
* It could be used to resolve the value via an external API and check if the returned value is valid or even existing.
* It must be implemented by the child classes as it is abstract.
* @returns {boolean} Whether the value is resolvable or not.
* @abstract
*/
abstract isResolvable(): boolean;

/**
* This method indicates if a value has the correct format or not.
* It is heavily recommended to use a regular expression to check the format.
Expand Down
20 changes: 0 additions & 20 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,3 @@ export const handleMap: Map<PID, PIDRecord> = new Map();
* @type {Set<PID>}
*/
export const unresolvables: Set<PID> = new Set();

/**
* Returns a user-friendly name of a locale.
* If the locale is a language, it will return the name of the language.
* If the locale is a region, it will return the flag of the region and the name of the region.
* @param locale The locale to get the name of.
* @param type The type of the locale.Either 'region' or 'language'.
* @returns {string} The user-friendly name of the locale.
*/
export function getLocaleDetail(locale: string, type: 'region' | 'language'): string {
const friendlyName = new Intl.DisplayNames(['en'], { type: type }).of(locale.toUpperCase());
if (type === 'language') return friendlyName;

const codePoints = locale
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt(0));
const flag = String.fromCodePoint(...codePoints);
return `${flag} ${friendlyName}`;
}

0 comments on commit 60ce8d5

Please sign in to comment.