From 9e06db79b5be7f3c82f1588cb71a97ba3592e847 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Mon, 12 Dec 2016 14:58:26 +1100 Subject: [PATCH] Add default frontend stylesheet --- assets/css/sportspress-rtl.css | 1 - assets/css/sportspress-style.css | 218 ++++++++++++++++++ assets/css/sportspress.css | 23 +- .../settings/class-sp-settings-general.php | 8 +- includes/class-sp-install.php | 4 + modules/sportspress-style.php | 136 +++++++++++ 6 files changed, 372 insertions(+), 18 deletions(-) create mode 100644 assets/css/sportspress-style.css create mode 100644 modules/sportspress-style.php diff --git a/assets/css/sportspress-rtl.css b/assets/css/sportspress-rtl.css index ae2df19f..8b93587e 100644 --- a/assets/css/sportspress-rtl.css +++ b/assets/css/sportspress-rtl.css @@ -36,7 +36,6 @@ .sp-player-list .data-name .player-flag { margin-right: 0; margin-left: 0.5em; - float: right; } /* Event Calendar */ diff --git a/assets/css/sportspress-style.css b/assets/css/sportspress-style.css new file mode 100644 index 00000000..97b35f93 --- /dev/null +++ b/assets/css/sportspress-style.css @@ -0,0 +1,218 @@ +/* SportsPress Templates */ + +.sp-template { + font-family: "Roboto", "Helvetica", sans-serif !important; + margin-bottom: 20px !important; +} + +.sp-template *, +.sp-data-table * { + text-transform: none !important; + letter-spacing: normal !important; +} + +/* Headings */ + +.sp-table-caption { + margin: 0 !important; + padding: 15px !important; + background: #fff !important; + border: 1px solid #e5e5e5 !important; + border-bottom: none !important; + font-size: 20px !important; + font-weight: 400 !important; + line-height: 1.5 !important; + display: table !important; + width: 100% !important; +} + +/* Links */ + +.sp-template a, +.sp-data-table a { + box-shadow: none !important; + text-decoration: none !important; + color: #00a69c !important; +} + +.sp-template a:hover, +.sp-data-table a:hover { + text-decoration: underline !important; +} + +.sp-view-all-link { + padding: 10px 15px !important; + margin: 0 !important; + background: #fff !important; + border: 1px solid #e5e5e5 !important; + border-top: none !important; + overflow: hidden !important; + display: table !important; + width: 100% !important; + text-align: right !important; +} + +.sp-view-all-link a { + font-size: 12px !important; + font-weight: 400 !important; + line-height: 1.5 !important; + text-decoration: none !important; + color: #999 !important; +} + +.sp-view-all-link a:hover { + color: #333 !important; +} + +.sp-form-event-link:hover { + text-decoration: none !important; +} + +/* Images */ + +.sp-template img { + box-shadow: none !important; +} + +/* Tables */ + +.sp-data-table { + color: #333 !important; + background: #fff !important; + border-collapse: collapse !important; + border: 1px solid #e5e5e5 !important; + width: 100% !important; +} + +.sp-data-table th, +.sp-data-table td { + font-size: 13px !important; + font-weight: 400 !important; + line-height: 1.5 !important; + border: 1px solid #e5e5e5 !important; + padding: 5px 10px !important; + text-align: center !important; +} + +.sp-data-table th { + font-size: 12px !important; + font-weight: 500 !important; + color: #999 !important; + border: none !important; +} + +.sp-data-table .data-name { + text-align: left !important; +} + +.sp-data-table .sp-highlight, +.sp-data-table .highlighted td { + font-weight: 500 !important; + background: #f9f9f9 !important; +} + +/* Galleries */ + +.sp-template-gallery .sp-gallery-wrapper { + border: 1px solid #e5e5e5 !important; + display: table; +} + +.sp-template-gallery .gallery-item { + padding: 0 !important; + margin: 0 !important; + position: relative !important; +} + +.sp-template-gallery .gallery-item a { + display: block !important; +} + +.sp-template-gallery .gallery-caption { + padding: 0 !important; + margin: 0 !important; + font-size: 12px !important; + font-style: normal !important; + font-weight: 500 !important; + text-align: center !important; + color: #999 !important; + line-height: 1.5 !important; + padding: 5px 10px !important; +} + +.sp-template-gallery .gallery-caption strong { + color: #fff !important; + background: #00a69c !important; + display: block !important; + font-weight: 400 !important; + font-size: 13px !important; + position: absolute !important; + left: 0 !important; + top: 0 !important; + padding: 5px 10px !important; +} + +/* Countdowns */ + +.sp-template-countdown h3, +.sp-template-countdown h5 { + margin: 0 !important; + padding: 5px 10px !important; + text-align: center !important; + line-height: 1.5 !important; + display: table !important; + width: 100% !important; + border: 1px solid #e5e5e5 !important; + border-bottom: none !important; +} + +.sp-template-countdown h3 { + font-size: 13px !important; + font-weight: 400 !important; + color: #333 !important; +} + +.sp-template-countdown h5 { + font-size: 12px !important; + font-weight: 500 !important; + color: #999 !important; +} + +.sp-template-countdown h5 a { + color: inherit !important; +} + +.sp-countdown time { + display: table !important; + border: 1px solid #e5e5e5 !important; + border-collapse: collapse !important; + width: 100% !important; +} + +.sp-countdown span { + font-size: 20px !important; + font-weight: 400 !important; + line-height: 1.5 !important; + display: table-cell !important; + border: 1px solid #e5e5e5 !important; + padding: 10px 5px !important; + text-align: center !important; +} + +.sp-countdown span small { + font-size: 12px !important; + font-weight: 400 !important; + line-height: 1.5 !important; + font-weight: 500 !important; + color: #999 !important; + color: #999 !important; + display: block !important; +} + +/* Media Queries */ + +@media screen and (min-width: 801px) { +} + +@media screen and (min-width: 601px) { +} \ No newline at end of file diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css index 8e015da7..b5e610ba 100644 --- a/assets/css/sportspress.css +++ b/assets/css/sportspress.css @@ -22,6 +22,7 @@ /* Templates */ .sp-template { margin-bottom: 1.5em; + overflow: hidden; } .sp-template-profile-selector { clear: both; @@ -180,8 +181,8 @@ width: 2em; height: 2em; margin-right: 0.5em; - display: block; - float: left; + display: inline-block; + vertical-align: middle; text-align: center; } .sp-league-table .data-name .team-logo img { @@ -200,8 +201,8 @@ width: 2em; height: 2em; margin-right: 0.5em; - display: block; - float: left; + display: inline-block; + vertical-align: middle; text-align: center; } .sp-player-list .data-name .player-photo img, @@ -422,17 +423,18 @@ text-align: left; } -.sp-form-event-link { +.sp-form-events .sp-form-event-link { display: inline-block; text-align: center; + line-height: 1.5em; width: 1.5em; margin: 0 0 0.25em; - color: #fff; + color: #fff !important; font-weight: normal; } -.sp-form-event-link:hover { - color: #fff; +.sp-form-events .sp-form-event-link:hover { + color: #fff !important; } /* Countdowns */ @@ -481,11 +483,6 @@ margin-top: 0.5em; } -/* Alternate */ -.sp-data-table tbody tr.odd { - background: rgba(0, 0, 0, 0.02); -} - /* Highlight & Heading */ .sp-highlight, .sp-heading { diff --git a/includes/admin/settings/class-sp-settings-general.php b/includes/admin/settings/class-sp-settings-general.php index eafb6366..578c8c2d 100644 --- a/includes/admin/settings/class-sp-settings-general.php +++ b/includes/admin/settings/class-sp-settings-general.php @@ -27,7 +27,7 @@ class SP_Settings_General extends SP_Settings_Page { add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) ); add_action( 'sportspress_admin_field_timezone', array( $this, 'timezone_setting' ) ); - add_action( 'sportspress_admin_field_frontend_styles', array( $this, 'frontend_styles_setting' ) ); + add_action( 'sportspress_admin_field_colors', array( $this, 'colors_setting' ) ); add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) ); } @@ -65,7 +65,7 @@ class SP_Settings_General extends SP_Settings_Page { ); $options = array( - array( 'type' => 'frontend_styles' ), + array( 'type' => 'colors' ), ); if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ): @@ -294,7 +294,7 @@ class SP_Settings_General extends SP_Settings_Page { * @access public * @return void */ - public function frontend_styles_setting() { + public function colors_setting() { // Define color schemes each with 5 colors: Primary, Background, Text, Heading, Link $color_schemes = apply_filters( 'sportspress_color_schemes', array( 'ThemeBoy' => array( '2b353e', 'f4f4f4', '222222', 'ffffff', '00a69c' ), @@ -308,7 +308,7 @@ class SP_Settings_General extends SP_Settings_Page { ) ); ?> - +
diff --git a/includes/class-sp-install.php b/includes/class-sp-install.php index 932f3a58..f7dceba0 100644 --- a/includes/class-sp-install.php +++ b/includes/class-sp-install.php @@ -423,6 +423,10 @@ class SP_Install { update_option( 'sportspress_staff_template_order', $layout ); } } + + if ( version_compare( $version, '2.2', '<' ) ) { + update_option( 'sportspress_frontend_styles', 'no' ); + } } /** diff --git a/modules/sportspress-style.php b/modules/sportspress-style.php new file mode 100644 index 00000000..62ca4cce --- /dev/null +++ b/modules/sportspress-style.php @@ -0,0 +1,136 @@ +define_constants(); + + // Add option + add_filter( 'sportspress_script_styling_options', array( $this, 'add_option' ) ); + + // Add stylesheet + add_filter( 'sportspress_enqueue_styles', array( $this, 'add_styles' ), 20 ); + + // Output custom CSS + add_action( 'sportspress_frontend_css', array( $this, 'custom_css' ), 40 ); + } + + /** + * Define constants. + */ + private function define_constants() { + if ( !defined( 'SP_STYLE_VERSION' ) ) + define( 'SP_STYLE_VERSION', '2.1.7' ); + + if ( !defined( 'SP_STYLE_URL' ) ) + define( 'SP_STYLE_URL', plugin_dir_url( __FILE__ ) ); + + if ( !defined( 'SP_STYLE_DIR' ) ) + define( 'SP_STYLE_DIR', plugin_dir_path( __FILE__ ) ); + } + + /** + * Add option. + */ + public static function add_option( $options = array() ) { + if ( ! current_theme_supports( 'sportspress' ) ): + array_unshift( $options, array( + 'title' => __( 'Frontend Styles', 'sportspress' ), + 'desc' => __( 'Enable', 'sportspress' ), + 'id' => 'sportspress_styles', + 'default' => 'yes', + 'type' => 'checkbox', + ) ); + endif; + return $options; + } + + /** + * Add stylesheet. + */ + public static function add_styles( $styles = array() ) { + if ( current_theme_supports( 'sportspress' ) ) return $styles; + if ( 'no' === get_option( 'sportspress_styles', 'yes' ) ) return $styles; + + $styles['sportspress-style'] = array( + 'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress-style.css', + 'deps' => '', + 'version' => SP_STYLE_VERSION, + 'media' => 'all' + ); + return $styles; + } + + /** + * Output custom CSS. + */ + public function custom_css( $colors = array() ) { + if ( current_theme_supports( 'sportspress' ) ) return $styles; + if ( 'no' === get_option( 'sportspress_styles', 'yes' ) ) return $styles; + + // Defaults + if ( empty( $colors['primary'] ) ) $colors['primary'] = '#2b353e'; + if ( empty( $colors['background'] ) ) $colors['background'] = '#f4f4f4'; + if ( empty( $colors['text'] ) ) $colors['text'] = '#222222'; + if ( empty( $colors['heading'] ) ) $colors['heading'] = '#ffffff'; + if ( empty( $colors['link'] ) ) $colors['link'] = '#00a69c'; + + // Calculate primary variations + $colors['primary_border'] = sp_hex_darker( $colors['primary'], 26, true ); + + // Calculate background variations + $colors['background_highlight'] = sp_hex_darker( $colors['background'], 6, true ); + $colors['background_border'] = sp_hex_darker( $colors['background'], 26, true ); + + // Calculate text variations + $rgb = sp_rgb_from_hex( $colors['text'] ); + $colors['text_muted'] = sp_hex_lighter( $colors['text'], 102, true ); + + // Primary + echo '.sp-data-table th,.sp-template-gallery .gallery-caption{background:' . $colors['primary'] . ' !important}'; + echo '.sp-data-table th{border-color:' . $colors['primary_border'] . ' !important}'; + + // Background + echo '.sp-table-caption,.sp-template .sp-view-all-link{background:' . $colors['background'] . ' !important}'; + echo '.sp-table-caption,.sp-data-table,.sp-data-table td,.sp-template .sp-view-all-link{border-color:' . $colors['background_border'] . ' !important}'; + echo '.sp-data-table .sp-highlight,.sp-data-table .highlighted td{background:' . $colors['background_highlight'] . ' !important}'; + + // Text + echo '.sp-table-caption,.sp-template .sp-view-all-link a:hover{color:' . $colors['text'] . ' !important}'; + echo '.sp-template .sp-view-all-link a{color:' . $colors['text_muted'] . ' !important}'; + + // Heading + echo '.sp-data-table th,.sp-template-gallery .gallery-caption{color:' . $colors['heading'] . ' !important}'; + + // Link + echo '.sp-template a{color:' . $colors['link'] . ' !important}'; + echo '.sp-template-gallery .gallery-caption strong{background:' . $colors['link'] . ' !important}'; + } +} + +endif; + +new SportsPress_Style();