Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magnify elements #283

Merged
merged 7 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
"femiwiki.css": "/* CSS placed here will affect users of the Femiwiki skin */",
"femiwiki.js": "/* Any JavaScript here will be loaded for users using the Femiwiki skin */",
"skin-femiwiki-desktop-switch-confirm": "Editing in mobile view is not supported yet. Would {{GENDER:|you}} like to switch to desktop view?",
"skin-femiwiki-desktop-switch-canceled": "Editing is canceled."
"skin-femiwiki-desktop-switch-canceled": "Editing is canceled.",
"prefs-femiwiki-large-elements-label": "User Larger Elements",
lens0021 marked this conversation as resolved.
Show resolved Hide resolved
lens0021 marked this conversation as resolved.
Show resolved Hide resolved
"prefs-femiwiki-large-elements-help": "The elements on the screen will be replaced by larger ones. This option lets you preview large elements."
}
4 changes: 3 additions & 1 deletion i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
"skin-femiwiki-share-facebook": "페이스북",
"skin-femiwiki-share-twitter": "트위터",
"skin-femiwiki-desktop-switch-confirm": "모바일 보기에서는 이 편집이 아직 지원되지 않습니다. 데스크톱 보기로 전환하시겠습니까?",
"skin-femiwiki-desktop-switch-canceled": "편집이 취소되었습니다."
"skin-femiwiki-desktop-switch-canceled": "편집이 취소되었습니다.",
"prefs-femiwiki-large-elements-label": "더 큰 요소 사용",
"prefs-femiwiki-large-elements-help": "화면의 요소들이 더 큰 요소들로 교체될 것입니다. 이 옵션은 큰 요소들을 미리 표시하게 합니다."
}
4 changes: 3 additions & 1 deletion i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
"femiwiki.css": "",
"femiwiki.js": "",
"skin-femiwiki-desktop-switch-confirm": "Confirm text for dialog to switch desktop view when the user tried to edit in mobile view",
"skin-femiwiki-desktop-switch-canceled": "Text for notification that is shown switching for editing is canceled."
"skin-femiwiki-desktop-switch-canceled": "Text for notification that is shown switching for editing is canceled.",
"prefs-femiwiki-large-elements-label": "Label for the checkbox to enable larger elements via Special:Preferences.",
"prefs-femiwiki-large-elements-help": "Detail explaining the operation of the prefs-femiwiki-large-elements-label checkbox."
}
10 changes: 10 additions & 0 deletions includes/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@ final class Constants {
* @var string
*/
public const CONFIG_KEY_SHOW_FOOTER_ICONS = 'FemiwikiShowFooterIcons';

/**
* @var string
*/
public const CONFIG_KEY_SMALL_ELEMENTS_FOR_ANONYMOUS_USER = 'FemiwikiLegacySmallElementsForAnonymousUser';

/**
* @var string
*/
public const PREF_KEY_LARGER_ELEMENTS = "FemiwikiUseLargerElements";
}
13 changes: 12 additions & 1 deletion includes/SkinFemiwiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,23 @@ class SkinFemiwiki extends SkinMustache {
* @inheritDoc
*/
public function __construct( $options = [] ) {
if ( $this->getUser()->isLoggedIn() ) {
$user = $this->getUser();
$loggedIn = $user->isLoggedIn();
$config = $this->getConfig();
$userOptionsLookup = MediaWikiServices::getInstance()->getUserOptionsLookup();

if ( $loggedIn ) {
$options['scripts'][] = 'skins.femiwiki.notifications';
}
if ( $this->shouldShowShare() ) {
$options['scripts'][] = 'skins.femiwiki.share';
}
if (
( !$loggedIn && $config->get( Constants::CONFIG_KEY_SMALL_ELEMENTS_FOR_ANONYMOUS_USER ) )
|| ( $loggedIn && $userOptionsLookup->getOption( $user, Constants::PREF_KEY_LARGER_ELEMENTS, '0' ) === '0' )
) {
$options['styles'][] = 'skins.femiwiki.smallElements';
}
parent::__construct( $options );
}

Expand Down
30 changes: 30 additions & 0 deletions includes/SmallElementsHooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace MediaWiki\Skins\Femiwiki;

class SmallElementsHooks implements \MediaWiki\Preferences\Hook\GetPreferencesHook {
/**
* @inheritDoc
*/
public function onGetPreferences( $user, &$preferences ) {
$newPrefs = [
Constants::PREF_KEY_LARGER_ELEMENTS => [
'type' => 'toggle',
'label-message' => 'prefs-femiwiki-large-elements-label',
'help-message' => 'prefs-femiwiki-large-elements-help',
'section' => 'rendering/skin/skin-prefs',
'hide-if' => [ '!==', 'wpskin', Constants::SKIN_NAME ],
]
];

$skinSectionIndex = array_search( 'skin', array_keys( $preferences ) );
if ( $skinSectionIndex !== false ) {
$newSectionIndex = $skinSectionIndex + 1;
$preferences = array_slice( $preferences, 0, $newSectionIndex, true )
+ $newPrefs
+ array_slice( $preferences, $newSectionIndex, null, true );
} else {
$preferences += $newPrefs;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ html.ve-deactivating {
}

.oo-ui-toolbar {
font-size: 12px;
font-size: 15px;
}
}

Expand Down
52 changes: 52 additions & 0 deletions resources/skins.femiwiki.smallElements/styles.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@import '../variables.less';

// Override variables.less
@font-size-root-default: 16.5;
@content-width: 50rem;

html {
font-size: unit(@font-size-root-default, px);
}

.nav-bar #mw-navigation {
max-width: @content-width - 1.3rem;
}

.fw-wiki-portals {
max-width: @content-width - @content-horizontal-padding;
}

#p-header,
.mw-body,
#p-lang,
.mw-footer {
max-width: @content-width;
}

hr#content-end-bar {
max-width: 47.4em;
lens0021 marked this conversation as resolved.
Show resolved Hide resolved
}

.fw-wiki-portals {
.mw-portlet {
@three-portlets-min-width: (@portal-min-width * 3) +
(@portal-column-gap * 2) + (@content-horizontal-padding * 2);
@four-portlets-min-width: (@portal-min-width * 4) + (@portal-column-gap * 3) +
(@content-horizontal-padding * 2);

@min-width: unit(@three-portlets-min-width * @font-size-root-default, px);
@max-width: unit(@four-portlets-min-width * @font-size-root-default, px);

@media (min-width: @min-width) and (max-width: @max-width) {
flex-basis: 40%;
}
}
}

html.ve-active,
html.ve-activated,
html.ve-deactivating {
.oo-ui-toolbar {
font-size: 12px !important;
}
}
8 changes: 7 additions & 1 deletion resources/skins.femiwiki/interface.less
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,19 @@

// End of content
hr#content-end-bar {
@padding: @content-horizontal-padding * 2;
border: 0;
border-width: 1px;
border-color: @color-primary2;
background-color: #a2a9b1;
max-width: 47.4em;
max-width: @content-width - @padding;
margin: 0 auto;
height: 1px;

@media (max-width: @width-breakpoint-mobile-small) {
@padding: @content-horizontal-padding-mobile-small * 2;
max-width: @content-width - @padding;
}
}

#p-lang {
Expand Down
7 changes: 4 additions & 3 deletions resources/variables.less
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@font-size-root-default: 16.5;
@font-size-root-default: 19;

@width-breakpoint-mobile-small: 360px;
@width-breakpoint-mobile: 480px;
@width-breakpoint-tablet: 640px;

@content-width: 50rem;
@content-width: 43.4rem;
@content-horizontal-padding: 1.3rem;
@content-horizontal-padding-mobile-small: 0.85rem;

@portal-min-width: 8.8rem;
@portal-column-gap: 0.8rem;
Expand Down Expand Up @@ -94,7 +95,7 @@
padding-left: @padding;
padding-right: @padding;
@media (max-width: @width-breakpoint-mobile-small) {
@padding: 0.85rem;
@padding: @content-horizontal-padding-mobile-small;
padding-left: @padding;
padding-right: @padding;
}
Expand Down
21 changes: 18 additions & 3 deletions skin.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@
"print.less"
]
},
"skins.femiwiki.smallElements": {
"class": "ResourceLoaderSkinModule",
lens0021 marked this conversation as resolved.
Show resolved Hide resolved
"features": {
"content-parser-output": false,
"toc": false
},
"targets": ["desktop", "mobile"],
"position": "top",
"styles": ["skins.femiwiki.smallElements/styles.less"]
},
"skins.femiwiki.xeicon": {
"class": "ResourceLoaderSkinModule",
"features": {
Expand Down Expand Up @@ -172,7 +182,10 @@
}
},
"HookHandlers": {
"default": { "class": "MediaWiki\\Skins\\Femiwiki\\Hooks" }
"default": { "class": "MediaWiki\\Skins\\Femiwiki\\Hooks" },
"SmallElements": {
"class": "MediaWiki\\Skins\\Femiwiki\\SmallElementsHooks"
}
},
"Hooks": {
"BeforePageDisplay": "MediaWiki\\Skins\\Femiwiki\\Hooks::onBeforePageDisplay",
Expand All @@ -181,7 +194,8 @@
"PersonalUrls": "MediaWiki\\Skins\\Femiwiki\\Hooks::onPersonalUrls",
"ResourceLoaderGetConfigVars": "MediaWiki\\Skins\\Femiwiki\\Hooks::onResourceLoaderGetConfigVars",
"UserMailerTransformContent": "MediaWiki\\Skins\\Femiwiki\\Hooks::onUserMailerTransformContent",
"SkinTemplateNavigation": "MediaWiki\\Skins\\Femiwiki\\Hooks::onSkinTemplateNavigation"
"SkinTemplateNavigation": "MediaWiki\\Skins\\Femiwiki\\Hooks::onSkinTemplateNavigation",
"GetPreferences": "SmallElements"
},
"config": {
"FemiwikiFirebaseKey": { "value": "" },
Expand All @@ -190,7 +204,8 @@
"FemiwikiHeadItems": { "value": false },
"FemiwikiAddThisId": { "value": false },
"FemiwikiUsePageLangForHeading": { "value": true },
"FemiwikiShowFooterIcons": { "value": false }
"FemiwikiShowFooterIcons": { "value": false },
"FemiwikiLegacySmallElementsForAnonymousUser": { "value": true }
},
"OOUIThemePaths": {
"Femiwiki": {
Expand Down