-
Notifications
You must be signed in to change notification settings - Fork 171
Fix Bug 1480106, on mobile, show browser name istead of icon #776
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,6 +456,42 @@ function writeNotes(support, browserId) { | |
return output; | ||
} | ||
|
||
/** | ||
* Formats the `browserNameKey` for display in the UI | ||
* @param {String} browserNameKey - The browser name | ||
* @returns Correctly formatted browser name | ||
*/ | ||
function getFormattedBrowserName(browserNameKey) { | ||
let firstChar; | ||
switch(browserNameKey) { | ||
case 'chrome': | ||
case 'edge': | ||
case 'firefox': | ||
case 'opera': | ||
case 'safari': | ||
firstChar = browserNameKey.charAt(0); | ||
return browserNameKey.replace(firstChar, firstChar.toUpperCase()); | ||
case 'ie': | ||
return browserNameKey.toUpperCase(); | ||
case 'webview_android': | ||
return 'Webview Android'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Webview -> WebView There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
case 'chrome_android': | ||
return 'Chrome Android'; | ||
case 'firefox_android': | ||
return 'Firefox Android'; | ||
case 'opera_android': | ||
return 'Opera Android'; | ||
case 'edge_mobile': | ||
return 'Edge Mobile'; | ||
case 'safari_ios': | ||
return 'Safari iOS'; | ||
case 'samsunginternet_android': | ||
return 'Samsung Internet Android'; | ||
default: | ||
return browserNameKey; | ||
} | ||
} | ||
|
||
/* | ||
For a single row, write all the cells that contain support data. | ||
(That is, every cell in the row except the first, which contains | ||
|
@@ -488,6 +524,7 @@ function writeCompatCells(supportData) { | |
supportInfo += getCellString(null); | ||
} | ||
|
||
let browserName = getFormattedBrowserName(browserNameKey); | ||
let supportClass = getSupportClass(support); | ||
output += `<td class="bc-supports-${supportClass} bc-browser-${browserNameKey}`; | ||
legendItems.add('support_' + supportClass); | ||
|
@@ -496,7 +533,7 @@ function writeCompatCells(supportData) { | |
output += ' bc-has-history'; | ||
} | ||
|
||
output += `">${supportInfo}`; | ||
output += `"><span class="bc-browser-name">${browserName}</span>${supportInfo}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having this hidden for now works for me. Note that we want to remove icons and use text everywhere and not just on mobile in the future. See #616. I'm not sure when we want to do this, though. Maybe now isn't the time for it. So this is OK with me 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. The scope of this was mobile specific, as that is where we will mostly see the use case of people turning of custom fonts. |
||
|
||
if (needsNotes) { | ||
output += writeCellIcons(support); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is OK for now. In the future, the formatted name should come from the compat data package.
(the export is
browsers.browserNameKey.name
), but we're missing two browsers still (see mdn/browser-compat-data#2690 and mdn/browser-compat-data#1712)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, that will make this much simpler.