ez326 commited on
Commit
62dcd3c
·
verified ·
1 Parent(s): c351604

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -16
app.py CHANGED
@@ -4,28 +4,29 @@ st.set_page_config(layout="wide")
4
 
5
  css = """
6
  <style>
7
- /* Remove margins/padding on markdown paragraphs */
8
  .stMarkdown p {
9
  margin: 0 !important;
10
  padding: 0 !important;
11
  }
12
- /* Hide empty markdown containers */
13
  div[data-testid="stMarkdownContainer"]:empty,
14
  p:empty {
15
  display: none !important;
16
  }
17
- /* Compact styling for criteria text */
18
  .criteria-name {
19
  font-size: 14px;
20
  font-weight: bold;
21
  margin-bottom: 0px;
22
  }
 
23
  .criteria-description {
24
  font-size: 12px;
25
  color: #555;
26
- margin-top: 0px;
27
- margin-bottom: 0px;
28
  }
 
29
  .subcriteria {
30
  margin-bottom: 0px;
31
  padding: 0px;
@@ -48,8 +49,7 @@ css = """
48
  width: 24px !important;
49
  height: 24px !important;
50
  }
51
- /* Hide slider tick marks, tick bar, min/max texts,
52
- and the empty label element that creates extra vertical space */
53
  div[data-baseweb="slider"] .Tick,
54
  div[data-baseweb="slider"] .TickBar,
55
  div[data-testid="stSliderTickBarMin"],
@@ -62,7 +62,7 @@ css = """
62
  .stSlider {
63
  margin-top: 0px !important;
64
  }
65
- /* Ensure header row stays inline on mobile */
66
  @media (max-width: 600px) {
67
  .stHorizontalBlock {
68
  flex-wrap: nowrap !important;
@@ -72,7 +72,6 @@ css = """
72
  padding-right: 2px !important;
73
  min-width: 0;
74
  }
75
- /* Reduce checkbox size on mobile */
76
  .stCheckbox {
77
  transform: scale(0.8);
78
  transform-origin: left center;
@@ -82,7 +81,7 @@ css = """
82
  """
83
  st.markdown(css, unsafe_allow_html=True)
84
 
85
- # Define criteria
86
  criteria = {
87
  "Writing": [
88
  {"name": "Dialogue", "description": "Word choice, realism, subtext, and implications."},
@@ -139,17 +138,22 @@ def calculate_score(ratings):
139
  st.markdown("<h1 class='app-header'>Movie Rating System</h1>", unsafe_allow_html=True)
140
  ratings = []
141
 
142
- # For each category and criterion, display:
143
- # - A header row with the criterion name and a small include checkbox,
144
- # - Immediately below, the description and the slider, with no extra vertical spacing.
 
 
145
  for group, subcriteria in criteria.items():
146
  st.markdown(f"<div class='category-header'>{group}</div>", unsafe_allow_html=True)
147
  for idx, crit in enumerate(subcriteria):
148
  with st.container():
149
- header_cols = st.columns([4, 0.5])
 
 
150
  header_cols[0].markdown(f"<span class='criteria-name'>{crit['name']}</span>", unsafe_allow_html=True)
151
- include = header_cols[1].checkbox("", value=True, key=f"include_{group}_{idx}")
152
- st.markdown(f"<div class='criteria-description'>{crit['description']}</div>", unsafe_allow_html=True)
 
153
  rating = st.slider("", 1.0, 7.0, 4.0, step=0.1, key=f"slider_{group}_{idx}", disabled=(not include))
154
  ratings.append(None if not include else rating)
155
 
 
4
 
5
  css = """
6
  <style>
7
+ /* Remove extra spacing in markdown paragraphs */
8
  .stMarkdown p {
9
  margin: 0 !important;
10
  padding: 0 !important;
11
  }
12
+ /* Hide empty markdown containers (that add unwanted space) */
13
  div[data-testid="stMarkdownContainer"]:empty,
14
  p:empty {
15
  display: none !important;
16
  }
17
+ /* Criterion name styling */
18
  .criteria-name {
19
  font-size: 14px;
20
  font-weight: bold;
21
  margin-bottom: 0px;
22
  }
23
+ /* Description styling: same style as header but slightly smaller */
24
  .criteria-description {
25
  font-size: 12px;
26
  color: #555;
27
+ margin: 0px;
 
28
  }
29
+ /* Container adjustments */
30
  .subcriteria {
31
  margin-bottom: 0px;
32
  padding: 0px;
 
49
  width: 24px !important;
50
  height: 24px !important;
51
  }
52
+ /* Hide slider tick marks, tick bar, min/max texts, and empty slider labels */
 
53
  div[data-baseweb="slider"] .Tick,
54
  div[data-baseweb="slider"] .TickBar,
55
  div[data-testid="stSliderTickBarMin"],
 
62
  .stSlider {
63
  margin-top: 0px !important;
64
  }
65
+ /* Mobile adjustments */
66
  @media (max-width: 600px) {
67
  .stHorizontalBlock {
68
  flex-wrap: nowrap !important;
 
72
  padding-right: 2px !important;
73
  min-width: 0;
74
  }
 
75
  .stCheckbox {
76
  transform: scale(0.8);
77
  transform-origin: left center;
 
81
  """
82
  st.markdown(css, unsafe_allow_html=True)
83
 
84
+ # Define criteria grouped by category with names and descriptions.
85
  criteria = {
86
  "Writing": [
87
  {"name": "Dialogue", "description": "Word choice, realism, subtext, and implications."},
 
138
  st.markdown("<h1 class='app-header'>Movie Rating System</h1>", unsafe_allow_html=True)
139
  ratings = []
140
 
141
+ # For each category and criterion, display a header row with:
142
+ # - the criterion name,
143
+ # - the description (inline, slightly smaller),
144
+ # - a small include checkbox.
145
+ # Then immediately display the slider below.
146
  for group, subcriteria in criteria.items():
147
  st.markdown(f"<div class='category-header'>{group}</div>", unsafe_allow_html=True)
148
  for idx, crit in enumerate(subcriteria):
149
  with st.container():
150
+ # Create one row with three columns:
151
+ # column0: criterion name; column1: description; column2: checkbox.
152
+ header_cols = st.columns([3, 4, 0.5])
153
  header_cols[0].markdown(f"<span class='criteria-name'>{crit['name']}</span>", unsafe_allow_html=True)
154
+ header_cols[1].markdown(f"<span class='criteria-description'>{crit['description']}</span>", unsafe_allow_html=True)
155
+ include = header_cols[2].checkbox("", value=True, key=f"include_{group}_{idx}")
156
+ # Slider appears immediately below
157
  rating = st.slider("", 1.0, 7.0, 4.0, step=0.1, key=f"slider_{group}_{idx}", disabled=(not include))
158
  ratings.append(None if not include else rating)
159